create-egregore 0.19.3 → 0.19.6
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 +410 -26
- package/bin/cli.js +34 -20
- package/lib/local.js +84 -11
- package/lib/pi-runtime.js +186 -0
- package/lib/setup.js +56 -11
- package/lib/ui.js +1 -1
- package/package.json +8 -6
- package/runtime/codex/.codex/hooks/search-hint.js +65 -0
- package/runtime/codex/.codex/hooks.json +13 -0
- package/runtime/codex/.codex/skills/deep-reflect/SKILL.md +14 -10
- package/runtime/codex/.codex/skills/minion/SKILL.md +25 -0
- package/runtime/codex/.codex/skills/scroll/SKILL.md +168 -0
- package/runtime/codex/.codex/skills/scroll/agents/openai.yaml +4 -0
- package/runtime/codex/.codex/skills/scroll/assets/shell.html +542 -0
- package/runtime/codex/.codex/skills/search/SKILL.md +56 -0
- package/runtime/codex/.codex/skills/session-view/SKILL.md +25 -0
- package/runtime/codex/.codex/skills/thread/SKILL.md +25 -0
- package/runtime/codex/.codex/skills/view/SKILL.md +147 -32
- package/runtime/codex/.codex/skills/view/agents/openai.yaml +4 -0
- package/runtime/codex/.codex/skills/view/assets/compose-scaffold.html +221 -0
- package/runtime/codex/.codex/spec-manifest.json +4 -4
- package/runtime/codex/AGENTS.md +31 -5
- package/runtime/codex/bin/activity-data.sh +46 -4
- package/runtime/codex/bin/agent.sh +10 -2
- package/runtime/codex/bin/codex-install-skills.sh +1 -1
- package/runtime/codex/bin/codex-render-spec.mjs +24 -2
- package/runtime/codex/bin/codex-session-start.sh +6 -60
- package/runtime/codex/bin/codex-skill-render.mjs +20 -12
- package/runtime/codex/bin/codex-sync-skills.sh +4 -0
- package/runtime/codex/bin/graph-op.sh +56 -5
- package/runtime/codex/bin/graph.sh +36 -0
- package/runtime/codex/bin/handoff-run.sh +157 -7
- package/runtime/codex/bin/handoff-save-egregore.sh +6 -1
- package/runtime/codex/bin/index-handoff.sh +9 -3
- package/runtime/codex/bin/lib/context.sh +97 -18
- package/runtime/codex/bin/lib/dashboard-artifact.sh +1 -1
- package/runtime/codex/bin/lib/git-sync.sh +35 -9
- package/runtime/codex/bin/lib/greeting.sh +30 -104
- package/runtime/codex/bin/lib/metrics.sh +374 -0
- package/runtime/codex/bin/publish-artifact.sh +43 -1
- package/runtime/codex/bin/settings.sh +274 -0
- package/runtime/codex/manifest.json +18 -1
- package/runtime/pi/.codex/config.toml +15 -0
- package/runtime/pi/.codex/hooks/branch-guard.js +242 -0
- package/runtime/pi/.codex/hooks/search-hint.js +65 -0
- package/runtime/pi/.codex/hooks.json +30 -0
- package/runtime/pi/.codex/skills/activity/SKILL.md +70 -0
- package/runtime/pi/.codex/skills/add/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/announce/SKILL.md +54 -0
- package/runtime/pi/.codex/skills/answer/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/archive/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/ask/SKILL.md +59 -0
- package/runtime/pi/.codex/skills/branch/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/checkup/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/commit/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/contribute/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/dark-mode/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/dashboard/SKILL.md +59 -0
- package/runtime/pi/.codex/skills/deep-reflect/SKILL.md +74 -0
- package/runtime/pi/.codex/skills/delete-user/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/egregore-voice/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/emissary/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/env/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/handoff/SKILL.md +67 -0
- package/runtime/pi/.codex/skills/harvest/SKILL.md +107 -0
- package/runtime/pi/.codex/skills/ingest/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/ingest-google/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/ingest-user-interview/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/invite/SKILL.md +40 -0
- package/runtime/pi/.codex/skills/issue/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/me/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/meeting/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/minion/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/note/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/onboarding/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/pr/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/project/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/pull/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/push/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/quest/SKILL.md +77 -0
- package/runtime/pi/.codex/skills/quest-suggest/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/reflect/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/review-pr/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/save/SKILL.md +62 -0
- package/runtime/pi/.codex/skills/scroll/SKILL.md +168 -0
- package/runtime/pi/.codex/skills/scroll/agents/openai.yaml +4 -0
- package/runtime/pi/.codex/skills/scroll/assets/shell.html +542 -0
- package/runtime/pi/.codex/skills/search/SKILL.md +56 -0
- package/runtime/pi/.codex/skills/session-view/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/setup/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/summon/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/sync-repos/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/telegram-connect/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/telemetry/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/test/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/the-spiral/SKILL.md +84 -0
- package/runtime/pi/.codex/skills/thread/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/todo/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/tui-design/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/tutorial/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/update/SKILL.md +25 -0
- package/runtime/pi/.codex/skills/view/SKILL.md +156 -0
- package/runtime/pi/.codex/skills/view/agents/openai.yaml +4 -0
- package/runtime/pi/.codex/skills/view/assets/compose-scaffold.html +221 -0
- package/runtime/pi/.codex/skills/visual-explain/SKILL.md +41 -0
- package/runtime/pi/.codex/skills/wrap/SKILL.md +55 -0
- package/runtime/pi/.codex/spec-manifest.json +114 -0
- package/runtime/pi/.pi/APPEND_SYSTEM.md +255 -0
- package/runtime/pi/.pi/extensions/egregore.ts +324 -0
- package/runtime/pi/.pi/settings.json +6 -0
- package/runtime/pi/.pi/spec-manifest.json +12 -0
- package/runtime/pi/AGENTS.md +350 -0
- package/runtime/pi/bin/activity-data.sh +242 -0
- package/runtime/pi/bin/agent.sh +677 -0
- package/runtime/pi/bin/codex-install-skills.sh +78 -0
- package/runtime/pi/bin/codex-render-spec.mjs +394 -0
- package/runtime/pi/bin/codex-session-start.sh +188 -0
- package/runtime/pi/bin/codex-skill-render.mjs +323 -0
- package/runtime/pi/bin/codex-sync-skills.sh +227 -0
- package/runtime/pi/bin/dashboard-data.sh +178 -0
- package/runtime/pi/bin/graph-batch.sh +60 -0
- package/runtime/pi/bin/graph-op.sh +431 -0
- package/runtime/pi/bin/graph-wal.sh +228 -0
- package/runtime/pi/bin/graph.sh +177 -0
- package/runtime/pi/bin/handoff-pr-backfill.sh +86 -0
- package/runtime/pi/bin/handoff-run.sh +581 -0
- package/runtime/pi/bin/handoff-save-egregore.sh +136 -0
- package/runtime/pi/bin/index-handoff.sh +312 -0
- package/runtime/pi/bin/lib/artifact-id.sh +46 -0
- package/runtime/pi/bin/lib/config.sh +71 -0
- package/runtime/pi/bin/lib/context.sh +542 -0
- package/runtime/pi/bin/lib/dashboard-artifact.sh +142 -0
- package/runtime/pi/bin/lib/ensure-develop.sh +183 -0
- package/runtime/pi/bin/lib/git-sync.sh +288 -0
- package/runtime/pi/bin/lib/greeting.sh +340 -0
- package/runtime/pi/bin/lib/hash.sh +13 -0
- package/runtime/pi/bin/lib/identity.sh +174 -0
- package/runtime/pi/bin/lib/metrics.sh +374 -0
- package/runtime/pi/bin/lib/permissions.sh +106 -0
- package/runtime/pi/bin/lib/time.sh +56 -0
- package/runtime/pi/bin/lib/worktree-links.sh +54 -0
- package/runtime/pi/bin/notify.sh +207 -0
- package/runtime/pi/bin/pi-branch-policy.mjs +15 -0
- package/runtime/pi/bin/pi-product-workflows.mjs +324 -0
- package/runtime/pi/bin/pi-render-spec.mjs +114 -0
- package/runtime/pi/bin/pi-session-start.sh +24 -0
- package/runtime/pi/bin/publish-artifact.sh +201 -0
- package/runtime/pi/bin/publish-references.sh +144 -0
- package/runtime/pi/bin/repo-state.sh +99 -0
- package/runtime/pi/bin/telemetry.sh +391 -0
- package/runtime/pi/bin/worktree-create.sh +118 -0
- package/runtime/pi/bin/worktree-remove.sh +50 -0
- package/runtime/pi/bin/worktree.sh +198 -0
- package/runtime/pi/manifest.json +176 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Make Egregore's project-local Codex skills available without duplicating
|
|
3
|
+
# them in CODEX_HOME.
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
7
|
+
SOURCE_DIR="$SCRIPT_DIR/.codex/skills"
|
|
8
|
+
HOOKS_FILE="$SCRIPT_DIR/.codex/hooks.json"
|
|
9
|
+
HOOKS_DIR="$SCRIPT_DIR/.codex/hooks"
|
|
10
|
+
CODEX_HOME_DIR="${CODEX_HOME:-$HOME/.codex}"
|
|
11
|
+
TARGET_DIR="$CODEX_HOME_DIR/skills"
|
|
12
|
+
|
|
13
|
+
[ -d "$SOURCE_DIR" ] || exit 0
|
|
14
|
+
|
|
15
|
+
# Current Codex discovers project skills via .agents/skills (and follows
|
|
16
|
+
# symlinks). The repo commits .agents/skills -> ../.codex/skills; repair it
|
|
17
|
+
# here for checkouts that lost the symlink (zip downloads, some Windows
|
|
18
|
+
# clones). Never clobber a real directory the user created.
|
|
19
|
+
AGENTS_DIR="$SCRIPT_DIR/.agents"
|
|
20
|
+
AGENTS_LINK="$AGENTS_DIR/skills"
|
|
21
|
+
if [ ! -e "$AGENTS_LINK" ] && [ ! -L "$AGENTS_LINK" ]; then
|
|
22
|
+
mkdir -p "$AGENTS_DIR"
|
|
23
|
+
ln -s ../.codex/skills "$AGENTS_LINK" 2>/dev/null || true
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
is_egregore_skill() {
|
|
27
|
+
local file="$1"
|
|
28
|
+
[ -f "$file" ] || return 1
|
|
29
|
+
grep -q 'Egregore' "$file" 2>/dev/null || return 1
|
|
30
|
+
grep -Eq 'bin/agent\.sh|bin/activity-data\.sh|bin/codex-skill-render\.mjs|Native Codex|generated-by: bin/codex-sync-skills\.sh|\.claude/skills' "$file" 2>/dev/null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
installed=0
|
|
34
|
+
for skill_dir in "$SOURCE_DIR"/*; do
|
|
35
|
+
[ -d "$skill_dir" ] || continue
|
|
36
|
+
[ -f "$skill_dir/SKILL.md" ] || continue
|
|
37
|
+
installed=$((installed + 1))
|
|
38
|
+
done
|
|
39
|
+
|
|
40
|
+
# Current Codex loads project-local .codex/skills from --cd. Older Egregore
|
|
41
|
+
# builds copied the same skills globally, which makes Codex show duplicates.
|
|
42
|
+
# Default to local-only and remove legacy global copies that are recognizably
|
|
43
|
+
# Egregore-managed. Set EGREGORE_CODEX_INSTALL_GLOBAL=1 for older Codex builds.
|
|
44
|
+
if [ "${EGREGORE_CODEX_INSTALL_GLOBAL:-0}" != "1" ]; then
|
|
45
|
+
removed=0
|
|
46
|
+
if [ -d "$TARGET_DIR" ]; then
|
|
47
|
+
for skill_dir in "$SOURCE_DIR"/*; do
|
|
48
|
+
[ -d "$skill_dir" ] || continue
|
|
49
|
+
[ -f "$skill_dir/SKILL.md" ] || continue
|
|
50
|
+
name="$(basename "$skill_dir")"
|
|
51
|
+
target="$TARGET_DIR/$name/SKILL.md"
|
|
52
|
+
if cmp -s "$skill_dir/SKILL.md" "$target" 2>/dev/null || is_egregore_skill "$target"; then
|
|
53
|
+
rm -rf "$TARGET_DIR/$name"
|
|
54
|
+
removed=$((removed + 1))
|
|
55
|
+
fi
|
|
56
|
+
done
|
|
57
|
+
fi
|
|
58
|
+
hooks_ready=0
|
|
59
|
+
if [ -f "$HOOKS_FILE" ] && [ -d "$HOOKS_DIR" ]; then
|
|
60
|
+
hooks_ready=1
|
|
61
|
+
fi
|
|
62
|
+
echo "codex project skills ready: $installed (removed global duplicates: $removed; hooks ready: $hooks_ready)"
|
|
63
|
+
exit 0
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
mkdir -p "$TARGET_DIR"
|
|
67
|
+
|
|
68
|
+
copied=0
|
|
69
|
+
for skill_dir in "$SOURCE_DIR"/*; do
|
|
70
|
+
[ -d "$skill_dir" ] || continue
|
|
71
|
+
[ -f "$skill_dir/SKILL.md" ] || continue
|
|
72
|
+
name="$(basename "$skill_dir")"
|
|
73
|
+
mkdir -p "$TARGET_DIR/$name"
|
|
74
|
+
cp -R "$skill_dir/." "$TARGET_DIR/$name/"
|
|
75
|
+
copied=$((copied + 1))
|
|
76
|
+
done
|
|
77
|
+
|
|
78
|
+
echo "codex global skills installed: $copied"
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Derive the Codex-native Egregore behavioral spec from CLAUDE.md.
|
|
3
|
+
//
|
|
4
|
+
// CLAUDE.md is the single source of truth for egregore behavior. Codex does
|
|
5
|
+
// not read CLAUDE.md — it reads AGENTS.md (root, concatenated, 32 KiB cap).
|
|
6
|
+
// This script renders CLAUDE.md into a generated block inside AGENTS.md the
|
|
7
|
+
// same way bin/codex-sync-skills.sh derives skills: deterministic transform,
|
|
8
|
+
// explicit per-section adaptation, manifest of what was adapted or dropped.
|
|
9
|
+
//
|
|
10
|
+
// node bin/codex-render-spec.mjs # render AGENTS.md + manifest
|
|
11
|
+
// node bin/codex-render-spec.mjs --check # exit 1 if rendered output is stale
|
|
12
|
+
//
|
|
13
|
+
// Adaptation rules (the DECIDED option-b translations):
|
|
14
|
+
// EnterWorktree -> bin/agent.sh branch / git checkout fallback
|
|
15
|
+
// AskUserQuestion -> numbered options in plain text
|
|
16
|
+
// hook-dependent behavior -> .codex/hooks equivalent where it exists,
|
|
17
|
+
// stated as an instruction where it doesn't
|
|
18
|
+
// Claude-only mechanics -> dropped explicitly (recorded in the manifest)
|
|
19
|
+
// /command tokens -> $skill tokens when a Codex skill of that name exists
|
|
20
|
+
//
|
|
21
|
+
// Manifest: .codex/spec-manifest.json — one entry per CLAUDE.md section with
|
|
22
|
+
// action (keep|replace), the source section hash, and a note explaining the
|
|
23
|
+
// translation. `replace` sections embed hand-authored Codex-native bodies;
|
|
24
|
+
// when the source section changes, the recorded hash goes stale and --check
|
|
25
|
+
// fails, forcing a review of the translation.
|
|
26
|
+
|
|
27
|
+
import fs from 'node:fs';
|
|
28
|
+
import path from 'node:path';
|
|
29
|
+
import crypto from 'node:crypto';
|
|
30
|
+
import { fileURLToPath } from 'node:url';
|
|
31
|
+
|
|
32
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
33
|
+
const CLAUDE_MD = path.join(ROOT, 'CLAUDE.md');
|
|
34
|
+
const AGENTS_MD = path.join(ROOT, 'AGENTS.md');
|
|
35
|
+
const MANIFEST = path.join(ROOT, '.codex', 'spec-manifest.json');
|
|
36
|
+
|
|
37
|
+
const BEGIN = '<!-- BEGIN GENERATED EGREGORE CODEX SPEC — derived from CLAUDE.md by bin/codex-render-spec.mjs; do not edit by hand -->';
|
|
38
|
+
const END = '<!-- END GENERATED EGREGORE CODEX SPEC -->';
|
|
39
|
+
|
|
40
|
+
// Hand-authored top of AGENTS.md, owned by this script so it can never be lost
|
|
41
|
+
// on regeneration. Opens with the runtime-precedence guard: Claude Code reads
|
|
42
|
+
// CLAUDE.md (and now loads root AGENTS.md automatically), so the first thing it
|
|
43
|
+
// must see here is an instruction to defer. Codex / shell-only agents read past
|
|
44
|
+
// the guard into the thin protocol and the generated spec below.
|
|
45
|
+
const AGENTS_PREAMBLE = `# Egregore Agent Protocol
|
|
46
|
+
|
|
47
|
+
> **Runtime precedence — read this first.**
|
|
48
|
+
>
|
|
49
|
+
> **If you are Claude Code** (or any agent that loads \`.claude/\`): **stop here.**
|
|
50
|
+
> Your authoritative instructions are \`CLAUDE.md\` and \`.claude/\`. Follow the
|
|
51
|
+
> SessionStart greeting and the branch-on-first-message rule there. Do **not**
|
|
52
|
+
> follow the startup steps below and do **not** use \`bin/agent.sh\` for work an
|
|
53
|
+
> Egregore skill already covers. This file exists only for runtimes that cannot
|
|
54
|
+
> read \`CLAUDE.md\`.
|
|
55
|
+
>
|
|
56
|
+
> **If you are Pi** (the \`pi\` coding-agent harness): **stop here.** Your
|
|
57
|
+
> authoritative Egregore instructions are loaded from
|
|
58
|
+
> \`.pi/APPEND_SYSTEM.md\`, and your workflows are exposed through the
|
|
59
|
+
> project-local \`.pi/\` runtime. Do not follow the Codex-specific block below.
|
|
60
|
+
>
|
|
61
|
+
> **If you are Codex or another shell-only agent:** this file is yours — continue.
|
|
62
|
+
|
|
63
|
+
Egregore is no longer only a Claude Code workspace. Claude Code remains the
|
|
64
|
+
first-class integrated runtime through \`.claude/\` and \`CLAUDE.md\`; any other
|
|
65
|
+
agent that can run shell commands in this checkout participates through the
|
|
66
|
+
portable memory protocol below.
|
|
67
|
+
|
|
68
|
+
## Startup
|
|
69
|
+
|
|
70
|
+
1. Read \`egregore.json\` for the instance name, GitHub owner, and managed repos.
|
|
71
|
+
2. Run \`bin/agent.sh sync\` to pull the latest shared memory.
|
|
72
|
+
3. Read \`memory/people/\` to learn collaborator handles.
|
|
73
|
+
4. Run \`bin/agent.sh activity --for <your-handle>\` to inspect handoffs and
|
|
74
|
+
pending questions addressed to you.
|
|
75
|
+
|
|
76
|
+
## Communication
|
|
77
|
+
|
|
78
|
+
Use the runtime-neutral bridge instead of Claude Code slash commands:
|
|
79
|
+
|
|
80
|
+
\`\`\`bash
|
|
81
|
+
bin/agent.sh branch --topic "auth review"
|
|
82
|
+
bin/agent.sh save --message "Save: auth review" --topic "auth review"
|
|
83
|
+
bin/agent.sh wrap --from alice --topic "auth review" \\
|
|
84
|
+
--summary "Implemented the OAuth callback parser and documented follow-ups." \\
|
|
85
|
+
--body "Open threads: review error cases and browser redirects."
|
|
86
|
+
|
|
87
|
+
bin/agent.sh handoff --from alice --to bob --topic "auth review" \\
|
|
88
|
+
--body "Implemented the OAuth callback parser. Bob should review error cases."
|
|
89
|
+
|
|
90
|
+
bin/agent.sh ask --from bob --to alice --topic "auth review" \\
|
|
91
|
+
--question "Should invalid state redirect to login or return 400?"
|
|
92
|
+
|
|
93
|
+
bin/agent.sh answer --from alice \\
|
|
94
|
+
--question memory/knowledge/questions/2026-04-26-bob-to-alice-auth-review.md \\
|
|
95
|
+
--body "Return 400 in the API path; redirect only in browser routes."
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
Each command writes to the existing Git-backed \`memory/\` repository and pushes
|
|
99
|
+
when the memory repo has an \`origin\` remote. Agents that cannot run shell may
|
|
100
|
+
write the same markdown files directly, following \`docs/AGENT-PROTOCOL.md\`.
|
|
101
|
+
|
|
102
|
+
## Handoffs vs Emissaries
|
|
103
|
+
|
|
104
|
+
\`bin/agent.sh handoff\` is the runtime-neutral path for internal team
|
|
105
|
+
session-handoffs: it writes to \`memory/handoffs/\`, updates the index, and uses
|
|
106
|
+
the same \`bin/handoff-run.sh\` machinery as Claude Code's \`/handoff\`.
|
|
107
|
+
|
|
108
|
+
Portable external capsules are **emissaries**, not team handoffs. Claude Code
|
|
109
|
+
routes those through \`/emissary\`; non-Claude agents should use the
|
|
110
|
+
\`egregore-emissary\` CLI/skill when it is installed. Do not use the deprecated
|
|
111
|
+
\`egregore-handoff\` CLI for Egregore project \`/handoff\` work.
|
|
112
|
+
|
|
113
|
+
## Compatibility
|
|
114
|
+
|
|
115
|
+
Claude Code users continue using \`/handoff\`, \`/activity\`, \`/ask\`, \`/save\`, and
|
|
116
|
+
other skills — driven by \`CLAUDE.md\`, not this file. Non-Claude agents use
|
|
117
|
+
\`bin/agent.sh\` and the file protocol, with the full Codex behavioral spec in the
|
|
118
|
+
generated block below. Both paths converge on the same \`memory/\` files.`;
|
|
119
|
+
|
|
120
|
+
function sha(text) {
|
|
121
|
+
return crypto.createHash('sha256').update(text).digest('hex').slice(0, 12);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ── fence-aware section splitter ────────────────────────────────────────
|
|
125
|
+
// Splits markdown into the intro (before the first H2) and one chunk per H2.
|
|
126
|
+
// `## ` lines inside ``` fences do not start sections.
|
|
127
|
+
function splitSections(markdown) {
|
|
128
|
+
const lines = markdown.split('\n');
|
|
129
|
+
const sections = [];
|
|
130
|
+
let current = { heading: '(intro)', body: [] };
|
|
131
|
+
let inFence = false;
|
|
132
|
+
for (const line of lines) {
|
|
133
|
+
if (/^```/.test(line.trim())) inFence = !inFence;
|
|
134
|
+
if (!inFence && /^## /.test(line)) {
|
|
135
|
+
sections.push(current);
|
|
136
|
+
current = { heading: line.replace(/^## /, '').trim(), body: [] };
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
current.body.push(line);
|
|
140
|
+
}
|
|
141
|
+
sections.push(current);
|
|
142
|
+
return sections.map((s) => ({ heading: s.heading, body: s.body.join('\n').replace(/^\n+/, '').replace(/\n+$/, '') }));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ── /command -> $skill token transform (outside code fences) ────────────
|
|
146
|
+
// Deterministic: every backticked /token becomes a $skill token except a
|
|
147
|
+
// static denylist of Claude Code harness features that are not Egregore
|
|
148
|
+
// skills on any runtime. Consulting the local .codex/skills directory here
|
|
149
|
+
// would make the rendered output depend on which instance ran the render
|
|
150
|
+
// (public checkouts carry fewer skills than the source repo).
|
|
151
|
+
const NON_SKILL_TOKENS = new Set(['loop', 'fast', 'config', 'clear', 'help']);
|
|
152
|
+
|
|
153
|
+
function transformTokens(body) {
|
|
154
|
+
const lines = body.split('\n');
|
|
155
|
+
let inFence = false;
|
|
156
|
+
const out = lines.map((line) => {
|
|
157
|
+
if (/^```/.test(line.trim())) {
|
|
158
|
+
inFence = !inFence;
|
|
159
|
+
return line;
|
|
160
|
+
}
|
|
161
|
+
if (inFence) return line;
|
|
162
|
+
return line.replace(/`\/([a-z][a-z0-9-]*)((?: [^`]*)?)`/g, (match, name, args) =>
|
|
163
|
+
NON_SKILL_TOKENS.has(name) ? match : `\`$${name}${args}\``
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
return out.join('\n');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ── hand-authored Codex-native section bodies ────────────────────────────
|
|
170
|
+
// Each is the option-b translation of the matching CLAUDE.md section. The
|
|
171
|
+
// manifest records the source hash so drift is caught by --check.
|
|
172
|
+
|
|
173
|
+
const INTRO_BODY = `You are a collaborator inside Egregore — a shared intelligence layer for organizations using AI coding agents. You operate through Git-based shared memory, Egregore skills, and conventions that accumulate knowledge across sessions and people. You are not a tool. You are a participant.
|
|
174
|
+
|
|
175
|
+
This block is the Codex-native Egregore behavioral spec, rendered from CLAUDE.md (the source of truth for egregore behavior) by \`bin/codex-render-spec.mjs\`. The per-section adaptation manifest is \`.codex/spec-manifest.json\`. The thin agent protocol above this block applies to every shell-capable agent; this block is the full behavioral contract for Codex sessions.`;
|
|
176
|
+
|
|
177
|
+
const ON_LAUNCH_BODY = `The \`egregore\` launcher renders the Egregore startup card (identity, team momentum, and pending work) via \`bin/codex-session-start.sh\` before Codex starts, and installs project skills. Do not rerun startup checks and do not narrate startup. The card ends with **"What are you working on?"** — that question is already on screen; treat the user's first message as the answer to it. To re-show the card, run \`bash bin/codex-session-start.sh --card\`.`;
|
|
178
|
+
|
|
179
|
+
const AFTER_GREETING_BODY = `**Mandatory behavioral rule.** When the user describes work, your **first action** — before reading files, exploring code, or anything else — is to get onto a working branch:
|
|
180
|
+
|
|
181
|
+
1. Derive a topic slug from what the user said (kebab-case, 2–4 words)
|
|
182
|
+
2. Run \`bin/agent.sh branch --topic "<topic>"\` — it creates a work branch from \`origin/develop\` in a task worktree (\`dev/{author}/{slug}\`, or \`feature/{slug}\` / \`bugfix/{slug}\` when the topic reads as a feature or fix) and prints the worktree path. Continue all file work from that printed path.
|
|
183
|
+
3. Confirm: \`On {branch} (worktree).\`
|
|
184
|
+
|
|
185
|
+
**Fallback:** If \`bin/agent.sh branch\` fails, use \`git checkout -b dev/{author}/{slug} origin/develop\`.
|
|
186
|
+
|
|
187
|
+
4. Update graph (fire-and-forget): \`bash bin/graph-op.sh set-topic "$(cat .egregore-session-id 2>/dev/null)" "topic from slug" "dev/author/slug" 2>/dev/null &\`
|
|
188
|
+
|
|
189
|
+
### Handoff claiming
|
|
190
|
+
|
|
191
|
+
If \`addressed_to_user\` handoffs exist and the user is picking one up, create the IMPLEMENTS link after branch creation:
|
|
192
|
+
\`\`\`bash
|
|
193
|
+
bash bin/graph-op.sh claim-handoff "$SESSION_ID" "$HANDOFF_SESSION_ID" 2>/dev/null &
|
|
194
|
+
\`\`\`
|
|
195
|
+
|
|
196
|
+
**Auto-checkout repos from handoff**: After claiming, check the \`addressed_rich\` context for \`repoState\`. If the handoff includes repo state (non-empty \`repoState\` array), check out the handoff's branches in each managed repo:
|
|
197
|
+
|
|
198
|
+
\`\`\`bash
|
|
199
|
+
PARENT_DIR="$(cd .. && pwd)"
|
|
200
|
+
# For each entry in repoState:
|
|
201
|
+
REPO_DIR="$PARENT_DIR/$REPO_NAME"
|
|
202
|
+
if [ -d "$REPO_DIR/.git" ] || [ -f "$REPO_DIR/.git" ]; then
|
|
203
|
+
git -C "$REPO_DIR" fetch origin "$BRANCH" --quiet 2>/dev/null
|
|
204
|
+
git -C "$REPO_DIR" checkout "$BRANCH" 2>/dev/null || \\
|
|
205
|
+
git -C "$REPO_DIR" checkout -b "$BRANCH" "origin/$BRANCH" 2>/dev/null
|
|
206
|
+
fi
|
|
207
|
+
\`\`\`
|
|
208
|
+
|
|
209
|
+
Report results: \`✓ Checked out {branch} in {repo1}, {repo2}\`. If a branch no longer exists (PR was merged): \`◐ {repo}: PR #{N} merged — on {base}\`. If \`repoState\` is absent or empty, skip auto-checkout silently.
|
|
210
|
+
|
|
211
|
+
**Exceptions** — skip branching when:
|
|
212
|
+
- The user explicitly created or named a branch themselves
|
|
213
|
+
- Already on a working branch AND the user's intent continues the current branch's topic
|
|
214
|
+
|
|
215
|
+
**Topic pivot while on a working branch:** If the user describes work **unrelated** to the current branch's topic, treat it as a new topic and create a new branch (\`bin/agent.sh branch --topic "<new topic>"\`). Do NOT mix unrelated work on one branch.
|
|
216
|
+
|
|
217
|
+
If on develop after two messages, create a branch immediately from whatever context you have.
|
|
218
|
+
|
|
219
|
+
### Branch-guard protocol
|
|
220
|
+
|
|
221
|
+
The \`.codex/hooks/branch-guard.js\` PreToolUse hook (enabled by the launcher via \`--enable hooks\`) denies writes, patches, and commits on \`develop\`/\`main\`/\`master\`. When it fires, choose between two paths based on how clear the topic is:
|
|
222
|
+
|
|
223
|
+
- **Topic is obvious from the last turn** (user said "fix X", "add Y feature") → auto-branch silently with \`bin/agent.sh branch --topic "<topic>"\` (or the git checkout fallback), then continue. Say one sentence ("Creating \`dev/{author}/{slug}\`.") so the user isn't confused about why a new branch appeared.
|
|
224
|
+
- **Topic is ambiguous** (open-ended exploration, user didn't specify what we're building yet) → ask **before** branching, in plain text with numbered options (Codex has no structured question tool):
|
|
225
|
+
|
|
226
|
+
\`\`\`text
|
|
227
|
+
Need a working branch first. Topic?
|
|
228
|
+
1. <suggested slug from context>
|
|
229
|
+
2. <alternative slug>
|
|
230
|
+
3. Other: (name it)
|
|
231
|
+
\`\`\`
|
|
232
|
+
|
|
233
|
+
Wait for the reply, then branch.
|
|
234
|
+
|
|
235
|
+
If this Codex build does not support hooks, follow the same discipline as a standing instruction: never write or commit on develop/main/master.
|
|
236
|
+
|
|
237
|
+
### Onboarding exception
|
|
238
|
+
|
|
239
|
+
If the startup card output contains \`onboarding_needed\`, invoke the \`$onboarding\` skill instead of greeting.`;
|
|
240
|
+
|
|
241
|
+
const COMMAND_AWARENESS_PREPEND = `Codex reserves leading \`/\` for built-ins, so Egregore workflows are **skills**, not slash commands. Invoke them with the matching \`$name\` skill token or from natural language intent ("show activity", "make a handoff"). Hand-written native Codex skills: \`$activity\`, \`$handoff\`, \`$wrap\`, \`$announce\`, \`$harvest\`, \`$the-spiral\`, \`$dashboard\`, \`$deep-reflect\`, \`$quest\`, \`$invite\`, \`$ask\`, \`$save\`, \`$view\`, and \`$scroll\`. Every other workflow has a generated adapter skill of the same name. \`$save\` is the user-facing abstraction for committing, pushing, opening or reusing pull requests, and syncing memory — never make users manage the git workflow by hand.`;
|
|
242
|
+
|
|
243
|
+
const SOCRATIC_BODY = `**Triggers**: "ask me questions", "question me", "help me think through", or any request to be questioned.
|
|
244
|
+
|
|
245
|
+
Codex has no structured question tool — render each batch as compact numbered questions in plain text, each with 2–4 lettered options plus an \`Other:\` line, then STOP and wait for the user's answers. Derive 2–4 context-specific questions per batch. Iteratively deepen based on answers. Converge toward decisions. After 4–5 rounds, synthesize and propose next steps. Route insights to \`$reflect\`.
|
|
246
|
+
|
|
247
|
+
**Rules:** Max 4 questions per batch. When choices aren't mutually exclusive, say "pick any that apply".`;
|
|
248
|
+
|
|
249
|
+
const LOOM_ROUTING_BODY = `Loom routes commands across model tiers on the Claude Code runtime (\`loom/routes.json\` + \`bin/loom.sh\` + a model-pinned executor subagent). Codex has no subagent delegation — every command runs inline in the current session. Ignore "Loom routing" preambles if you encounter them in a skill spec, and skip \`bin/loom.sh\` calls; \`loom/\` and \`.claude/agents/\` are framework files synced for the Claude runtime.`;
|
|
250
|
+
|
|
251
|
+
const ISOLATION_BODY = `Sessions are confined to this project + memory + managed repos. On Codex this boundary is a standing instruction, not an enforced hook — hold it yourself.
|
|
252
|
+
|
|
253
|
+
- **Never modify \`~/.egregore/instances.json\`** — managed by session-start.sh
|
|
254
|
+
- **Never access another instance's files** — refuse even if asked
|
|
255
|
+
- When a request points outside the boundary, do not improvise a workaround. Ask in plain text with numbered options:
|
|
256
|
+
|
|
257
|
+
\`\`\`text
|
|
258
|
+
That path is outside this Egregore's boundary. How should we proceed?
|
|
259
|
+
1. Paste the contents inline
|
|
260
|
+
2. Move the file into the repo and point me at the new path
|
|
261
|
+
3. Cancel
|
|
262
|
+
\`\`\`
|
|
263
|
+
|
|
264
|
+
See DEVELOPMENT.md §3 for boundary details.`;
|
|
265
|
+
|
|
266
|
+
// ── per-section rules ────────────────────────────────────────────────────
|
|
267
|
+
const RULES = {
|
|
268
|
+
'(intro)': {
|
|
269
|
+
action: 'replace',
|
|
270
|
+
body: INTRO_BODY,
|
|
271
|
+
note: 'Reframed for Codex: names AGENTS.md as the delivery surface and the manifest; "organizations using Claude Code" generalized.',
|
|
272
|
+
},
|
|
273
|
+
'Identity & Upstream': {
|
|
274
|
+
action: 'keep',
|
|
275
|
+
note: 'Kept; /update, /contribute, /save tokens rendered as $skill tokens.',
|
|
276
|
+
},
|
|
277
|
+
'On Launch — MANDATORY FIRST ACTION': {
|
|
278
|
+
action: 'replace',
|
|
279
|
+
body: ON_LAUNCH_BODY,
|
|
280
|
+
note: 'Claude SessionStart hook does not run on Codex; the egregore launcher renders the card via bin/codex-session-start.sh before the session. Greeting-replay instruction dropped (card is already on screen).',
|
|
281
|
+
},
|
|
282
|
+
'After Greeting — BRANCH ON FIRST RESPONSE': {
|
|
283
|
+
action: 'replace',
|
|
284
|
+
body: AFTER_GREETING_BODY,
|
|
285
|
+
note: 'EnterWorktree -> bin/agent.sh branch with git checkout fallback; AskUserQuestion -> numbered options in plain text; branch-guard mapped to .codex/hooks/branch-guard.js with instruction fallback; plan-mode note dropped (no plan mode on Codex); /branch + /onboarding -> skill tokens. Handoff claiming and repoState auto-checkout kept verbatim (pure git).',
|
|
286
|
+
},
|
|
287
|
+
'Config Files': { action: 'keep', note: 'Kept verbatim — shell facts, runtime-neutral.' },
|
|
288
|
+
'Knowledge Graph': { action: 'keep', note: 'Kept verbatim — bin/graph.sh is runtime-neutral.' },
|
|
289
|
+
'Notifications': { action: 'keep', note: 'Kept verbatim — bin/notify.sh is runtime-neutral.' },
|
|
290
|
+
'Onboarding': { action: 'keep', note: 'Kept; /onboarding rendered as $onboarding.' },
|
|
291
|
+
'Transparency Beat': { action: 'keep', note: 'Kept verbatim.' },
|
|
292
|
+
'Memory': { action: 'keep', note: 'Kept verbatim.' },
|
|
293
|
+
'Loom Routing': {
|
|
294
|
+
action: 'replace',
|
|
295
|
+
body: LOOM_ROUTING_BODY,
|
|
296
|
+
note: 'Loom delegation rides the Claude Code Agent tool; Codex has no subagent delegation — commands run inline. Preambles and bin/loom.sh calls marked skippable.',
|
|
297
|
+
},
|
|
298
|
+
'Git Workflow': {
|
|
299
|
+
action: 'keep',
|
|
300
|
+
note: 'Kept; slash tokens rendered as $skill tokens. Branch diagram unchanged (code fence).',
|
|
301
|
+
},
|
|
302
|
+
'Working Conventions': { action: 'keep', note: 'Kept verbatim.' },
|
|
303
|
+
'Command Awareness': {
|
|
304
|
+
action: 'keep',
|
|
305
|
+
prepend: COMMAND_AWARENESS_PREPEND,
|
|
306
|
+
note: 'Prepended the Codex command surface (skill tokens, native vs adapter split, $save abstraction); disambiguation map kept with /x -> $x token rendering. Tokens with no Codex skill (e.g. /loop, a Claude Code harness feature) are left as-is.',
|
|
307
|
+
},
|
|
308
|
+
'Socratic Questioning (MANDATORY)': {
|
|
309
|
+
action: 'replace',
|
|
310
|
+
body: SOCRATIC_BODY,
|
|
311
|
+
note: 'AskUserQuestion -> numbered plain-text question batches with explicit stop-and-wait; multiSelect -> "pick any that apply".',
|
|
312
|
+
},
|
|
313
|
+
'Telemetry': { action: 'keep', note: 'Kept verbatim — bin/telemetry.sh is runtime-neutral.' },
|
|
314
|
+
'Mode': { action: 'keep', note: 'Kept; /env and /checkup rendered as $skill tokens.' },
|
|
315
|
+
'Environment Isolation': {
|
|
316
|
+
action: 'replace',
|
|
317
|
+
body: ISOLATION_BODY,
|
|
318
|
+
note: 'boundary-check is a Claude PreToolUse hook with no .codex equivalent — behavior stated as a standing instruction; AskUserQuestion remediation -> numbered options.',
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// ── render ───────────────────────────────────────────────────────────────
|
|
323
|
+
function render() {
|
|
324
|
+
const claudeMd = fs.readFileSync(CLAUDE_MD, 'utf-8');
|
|
325
|
+
const sections = splitSections(claudeMd);
|
|
326
|
+
|
|
327
|
+
const manifest = [];
|
|
328
|
+
const parts = [];
|
|
329
|
+
|
|
330
|
+
for (const section of sections) {
|
|
331
|
+
const rule = RULES[section.heading];
|
|
332
|
+
if (!rule) {
|
|
333
|
+
console.error(`codex-render-spec: no rule for CLAUDE.md section "${section.heading}" — add one to RULES in bin/codex-render-spec.mjs`);
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
const sourceHash = sha(section.body);
|
|
337
|
+
manifest.push({ section: section.heading, action: rule.action, sourceHash, note: rule.note });
|
|
338
|
+
|
|
339
|
+
const heading = section.heading === '(intro)' ? '## Egregore on Codex' : `## ${section.heading}`;
|
|
340
|
+
let body;
|
|
341
|
+
if (rule.action === 'replace') {
|
|
342
|
+
body = rule.body;
|
|
343
|
+
} else {
|
|
344
|
+
body = transformTokens(section.body);
|
|
345
|
+
if (rule.prepend) body = `${rule.prepend}\n\n${body}`;
|
|
346
|
+
}
|
|
347
|
+
parts.push(`${heading}\n\n${body}`);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
for (const heading of Object.keys(RULES)) {
|
|
351
|
+
if (!sections.some((s) => s.heading === heading)) {
|
|
352
|
+
console.error(`codex-render-spec: RULES contains "${heading}" but CLAUDE.md has no such section — remove or update the rule`);
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const block = `${BEGIN}\n\n${parts.join('\n\n---\n\n')}\n\n${END}`;
|
|
358
|
+
return { block, manifest };
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// AGENTS.md is fully owned by this script: the guard preamble plus the generated
|
|
362
|
+
// spec block. Reconstructing it deterministically (rather than splicing into the
|
|
363
|
+
// existing file) guarantees the runtime-precedence guard is always present and
|
|
364
|
+
// correct — it cannot be stripped by an upstream sync or a hand edit.
|
|
365
|
+
function assembleAgentsMd(block) {
|
|
366
|
+
return `${AGENTS_PREAMBLE.trim()}\n\n${block}\n`;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const check = process.argv.includes('--check');
|
|
370
|
+
const { block, manifest } = render();
|
|
371
|
+
const manifestJson = `${JSON.stringify({ generatedBy: 'bin/codex-render-spec.mjs', source: 'CLAUDE.md', sections: manifest }, null, 2)}\n`;
|
|
372
|
+
|
|
373
|
+
const currentAgents = fs.existsSync(AGENTS_MD) ? fs.readFileSync(AGENTS_MD, 'utf-8') : '';
|
|
374
|
+
const nextAgents = assembleAgentsMd(block);
|
|
375
|
+
|
|
376
|
+
const CODEX_DOC_BUDGET = 32 * 1024;
|
|
377
|
+
if (Buffer.byteLength(nextAgents, 'utf-8') > CODEX_DOC_BUDGET) {
|
|
378
|
+
console.error(`codex-render-spec: AGENTS.md would be ${Buffer.byteLength(nextAgents, 'utf-8')} bytes — over Codex's ${CODEX_DOC_BUDGET}-byte project-doc budget. Trim CLAUDE.md or tighten translations.`);
|
|
379
|
+
process.exit(1);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (check) {
|
|
383
|
+
const currentManifest = fs.existsSync(MANIFEST) ? fs.readFileSync(MANIFEST, 'utf-8') : '';
|
|
384
|
+
const stale = nextAgents !== currentAgents || manifestJson !== currentManifest;
|
|
385
|
+
if (stale) {
|
|
386
|
+
console.error('codex spec out of date — run: node bin/codex-render-spec.mjs');
|
|
387
|
+
process.exit(1);
|
|
388
|
+
}
|
|
389
|
+
console.log('codex spec up to date');
|
|
390
|
+
} else {
|
|
391
|
+
fs.writeFileSync(AGENTS_MD, nextAgents);
|
|
392
|
+
fs.writeFileSync(MANIFEST, manifestJson);
|
|
393
|
+
console.log(`codex spec rendered: AGENTS.md (${Buffer.byteLength(nextAgents, 'utf-8')} bytes), .codex/spec-manifest.json (${manifest.length} sections)`);
|
|
394
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -o pipefail
|
|
3
|
+
|
|
4
|
+
# Codex does not run Claude Code SessionStart hooks. This is the runtime-neutral
|
|
5
|
+
# startup card: it reuses the same identity, git sync, and context-gathering
|
|
6
|
+
# libraries as Claude's SessionStart, then renders a terminal greeting before
|
|
7
|
+
# Codex itself starts.
|
|
8
|
+
|
|
9
|
+
FRAMEWORK_VERSION="6"
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
11
|
+
cd "$SCRIPT_DIR" || exit 1
|
|
12
|
+
|
|
13
|
+
IS_WORKTREE="false"
|
|
14
|
+
MAIN_PROJECT_DIR="$SCRIPT_DIR"
|
|
15
|
+
if [ -f "$SCRIPT_DIR/.git" ]; then
|
|
16
|
+
IS_WORKTREE="true"
|
|
17
|
+
WT_GITDIR=$(sed 's/^gitdir: //' "$SCRIPT_DIR/.git" 2>/dev/null)
|
|
18
|
+
MAIN_PROJECT_DIR=$(cd "$WT_GITDIR/../../.." 2>/dev/null && pwd)
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
# Clear any branch-guard consent from a previous session — consent to write on
|
|
22
|
+
# a protected branch is asked fresh each session (see AGENTS.md branch-guard protocol).
|
|
23
|
+
rm -f "$SCRIPT_DIR/.egregore-branch-consent" "$MAIN_PROJECT_DIR/.egregore-branch-consent" 2>/dev/null
|
|
24
|
+
|
|
25
|
+
if [ -f "$SCRIPT_DIR/bin/lib/worktree-links.sh" ]; then
|
|
26
|
+
source "$SCRIPT_DIR/bin/lib/worktree-links.sh" >/dev/null 2>/dev/null || true
|
|
27
|
+
egregore_link_shared_state "$SCRIPT_DIR" "$MAIN_PROJECT_DIR" >/dev/null 2>/dev/null || true
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
HEALTH_GITHUB="skip"
|
|
31
|
+
HEALTH_GIT="skip"
|
|
32
|
+
HEALTH_APIKEY="skip"
|
|
33
|
+
HEALTH_GRAPH="skip"
|
|
34
|
+
HEALTH_TELEGRAM="skip"
|
|
35
|
+
|
|
36
|
+
STATE_FILE="$SCRIPT_DIR/.egregore-state.json"
|
|
37
|
+
ENV_FILE="$SCRIPT_DIR/.env"
|
|
38
|
+
CONFIG="$SCRIPT_DIR/egregore.json"
|
|
39
|
+
DATE=$(date +%Y-%m-%d)
|
|
40
|
+
|
|
41
|
+
source "$SCRIPT_DIR/bin/lib/config.sh"
|
|
42
|
+
source "$SCRIPT_DIR/bin/lib/hash.sh"
|
|
43
|
+
source "$SCRIPT_DIR/bin/lib/time.sh"
|
|
44
|
+
source "$SCRIPT_DIR/bin/lib/identity.sh" >/dev/null 2>/dev/null
|
|
45
|
+
|
|
46
|
+
LOCAL_MODE="false"
|
|
47
|
+
[ "$(_detect_mode)" = "local" ] && LOCAL_MODE="true"
|
|
48
|
+
|
|
49
|
+
if [ "$LOCAL_MODE" != "true" ]; then
|
|
50
|
+
if [ -f "$ENV_FILE" ] && grep -q '^EGREGORE_API_KEY=.' "$ENV_FILE" 2>/dev/null; then
|
|
51
|
+
HEALTH_APIKEY="ok"
|
|
52
|
+
else
|
|
53
|
+
HEALTH_APIKEY="fail"
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
source "$SCRIPT_DIR/bin/lib/git-sync.sh" >/dev/null 2>/dev/null
|
|
58
|
+
source "$SCRIPT_DIR/bin/lib/context.sh" >/dev/null 2>/dev/null
|
|
59
|
+
source "$SCRIPT_DIR/bin/lib/metrics.sh" >/dev/null 2>/dev/null
|
|
60
|
+
trap 'rm -rf "${CTX_DIR:-}"' EXIT
|
|
61
|
+
|
|
62
|
+
read_json() {
|
|
63
|
+
local file="$1"
|
|
64
|
+
local expr="$2"
|
|
65
|
+
local fallback="${3:-}"
|
|
66
|
+
if [ -f "$file" ] && command -v jq >/dev/null 2>&1; then
|
|
67
|
+
jq -r "$expr // empty" "$file" 2>/dev/null | head -1
|
|
68
|
+
else
|
|
69
|
+
printf '%s\n' "$fallback"
|
|
70
|
+
fi
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ORG_NAME="$(read_json "$CONFIG" '.org_name' '')"
|
|
74
|
+
[ -z "$ORG_NAME" ] && ORG_NAME="$(read_json "$CONFIG" '.slug' 'Egregore')"
|
|
75
|
+
GITHUB_ORG="$(read_json "$CONFIG" '.github_org' '')"
|
|
76
|
+
REPO_NAME="$(read_json "$CONFIG" '.repo_name' 'egregore')"
|
|
77
|
+
SLUG="$(read_json "$CONFIG" '.slug' '')"
|
|
78
|
+
DISPLAY_NAME="$(read_json "$STATE_FILE" '.display_name' '')"
|
|
79
|
+
[ -z "$DISPLAY_NAME" ] && DISPLAY_NAME="${DISPLAY_NAME_STATE:-$AUTHOR}"
|
|
80
|
+
ONBOARDING_COMPLETE="$(read_json "$STATE_FILE" '.onboarding_complete' '')"
|
|
81
|
+
[ -z "$ONBOARDING_COMPLETE" ] && ONBOARDING_COMPLETE="unknown"
|
|
82
|
+
|
|
83
|
+
ADDRESSED_RICH="$(cat "$CTX_DIR/addressed_rich" 2>/dev/null || echo "[]")"
|
|
84
|
+
PENDING_Q="$(cat "$CTX_DIR/pending_questions" 2>/dev/null || echo "[]")"
|
|
85
|
+
ADDRESSED_COUNT="$(echo "$ADDRESSED_RICH" | jq 'length' 2>/dev/null || echo "0")"
|
|
86
|
+
PENDING_Q_COUNT="$(echo "$PENDING_Q" | jq 'length' 2>/dev/null || echo "0")"
|
|
87
|
+
|
|
88
|
+
render_pending_line() {
|
|
89
|
+
if [ "$PENDING_Q_COUNT" -gt 0 ] 2>/dev/null; then
|
|
90
|
+
local senders noun
|
|
91
|
+
senders="$(echo "$PENDING_Q" | jq -r '[.[].from] | unique | join(", ")' 2>/dev/null)"
|
|
92
|
+
[ "$PENDING_Q_COUNT" = "1" ] && noun="question" || noun="questions"
|
|
93
|
+
if [ -n "$senders" ]; then
|
|
94
|
+
printf ' ◐ %s pending %s from %s - bin/agent.sh answer\n' "$PENDING_Q_COUNT" "$noun" "$senders"
|
|
95
|
+
else
|
|
96
|
+
printf ' ◐ %s pending %s - bin/agent.sh answer\n' "$PENDING_Q_COUNT" "$noun"
|
|
97
|
+
fi
|
|
98
|
+
elif [ "$ADDRESSED_COUNT" -gt 0 ] 2>/dev/null; then
|
|
99
|
+
printf ' ◇ %s handoffs for %s - bin/agent.sh activity --for %s\n' "$ADDRESSED_COUNT" "$AUTHOR" "$AUTHOR"
|
|
100
|
+
fi
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
banner() {
|
|
104
|
+
cat <<'EOF'
|
|
105
|
+
|
|
106
|
+
███████╗ ██████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗
|
|
107
|
+
██╔════╝██╔════╝ ██╔══██╗██╔════╝██╔════╝ ██╔═══██╗██╔══██╗██╔════╝
|
|
108
|
+
█████╗ ██║ ███╗██████╔╝█████╗ ██║ ███╗██║ ██║██████╔╝█████╗
|
|
109
|
+
██╔══╝ ██║ ██║██╔══██╗██╔══╝ ██║ ██║██║ ██║██╔══██╗██╔══╝
|
|
110
|
+
███████╗╚██████╔╝██║ ██║███████╗╚██████╔╝╚██████╔╝██║ ██║███████╗
|
|
111
|
+
╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
112
|
+
|
|
113
|
+
EOF
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
render_card() {
|
|
117
|
+
local separator identity_left identity_right line_width pad footer_left footer_right board_url has_failure failed_services
|
|
118
|
+
separator=" ..................................................................."
|
|
119
|
+
identity_left=" ${GITHUB_ORG:-$ORG_NAME}/${REPO_NAME}"
|
|
120
|
+
identity_right="${DISPLAY_NAME} · ${BRANCH:-?}"
|
|
121
|
+
line_width=67
|
|
122
|
+
pad=$((line_width - ${#identity_left} - ${#identity_right}))
|
|
123
|
+
[ "$pad" -lt 1 ] && pad=1
|
|
124
|
+
|
|
125
|
+
banner
|
|
126
|
+
printf '%s%*s%s\n' "$identity_left" "$pad" "" "$identity_right"
|
|
127
|
+
printf '%s\n' "$separator"
|
|
128
|
+
SEPARATOR="$separator" LINE_WIDTH=$line_width _render_momentum_board
|
|
129
|
+
render_pending_line
|
|
130
|
+
printf '%s\n' "$separator"
|
|
131
|
+
|
|
132
|
+
has_failure="false"
|
|
133
|
+
failed_services=""
|
|
134
|
+
for pair in "github:$HEALTH_GITHUB" "git:$HEALTH_GIT" "api-key:$HEALTH_APIKEY" "graph:$HEALTH_GRAPH" "telegram:$HEALTH_TELEGRAM"; do
|
|
135
|
+
svc="${pair%%:*}"
|
|
136
|
+
svc_status="${pair#*:}"
|
|
137
|
+
if [ "$svc_status" = "fail" ]; then
|
|
138
|
+
has_failure="true"
|
|
139
|
+
failed_services="${failed_services} ${svc} ✗"
|
|
140
|
+
fi
|
|
141
|
+
done
|
|
142
|
+
|
|
143
|
+
if [ "$has_failure" = "true" ]; then
|
|
144
|
+
printf ' ⚠%s\n' "$failed_services"
|
|
145
|
+
else
|
|
146
|
+
footer_left=" ✓ ready"
|
|
147
|
+
if [ "${MEMORY_SYNCED:-false}" = "true" ]; then
|
|
148
|
+
footer_right="◆ memory synced"
|
|
149
|
+
else
|
|
150
|
+
footer_right="◆ memory not synced"
|
|
151
|
+
fi
|
|
152
|
+
pad=$((line_width - ${#footer_left} - ${#footer_right}))
|
|
153
|
+
[ "$pad" -lt 1 ] && pad=1
|
|
154
|
+
printf '%s%*s%s\n' "$footer_left" "$pad" "" "$footer_right"
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
if [ -n "$SLUG" ]; then
|
|
158
|
+
board_url="https://egregore.xyz/view/${SLUG}/board"
|
|
159
|
+
printf ' ◆ %s\n' "$board_url"
|
|
160
|
+
fi
|
|
161
|
+
printf '\nWhat are you working on?\n'
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
case "${1:---card}" in
|
|
165
|
+
--card|card)
|
|
166
|
+
render_card
|
|
167
|
+
;;
|
|
168
|
+
--prompt|prompt)
|
|
169
|
+
cat <<EOF
|
|
170
|
+
You are Codex running inside Egregore for ${ORG_NAME} as ${AUTHOR}.
|
|
171
|
+
The launcher already rendered the Egregore startup card using the shared identity, git-sync, graph, and filesystem context pipeline.
|
|
172
|
+
This session is Trusted Codex: full shell/network access is enabled and approval prompts are disabled by the launcher.
|
|
173
|
+
Do not rerun startup checks or narrate startup unless the user asks.
|
|
174
|
+
Follow AGENTS.md before code changes.
|
|
175
|
+
After the user names what they are working on, use bin/agent.sh branch --topic "<work topic>" if you are not already in an appropriate task worktree, then continue file work from the printed worktree path.
|
|
176
|
+
Use bin/agent.sh to update shared activity: handoff, ask, and answer write to memory/ and push when possible.
|
|
177
|
+
Use bin/agent.sh handoff for internal team session-handoffs. Portable external capsules are emissaries; use egregore-emissary when installed, not the deprecated egregore-handoff CLI.
|
|
178
|
+
Codex reserves leading slash commands for built-ins, so custom Egregore /activity-style commands will not reach the agent. Egregore native Codex skills are: \$activity, \$handoff, \$wrap, \$announce, \$harvest, \$the-spiral, \$dashboard, \$deep-reflect, \$quest, \$invite, \$ask, \$save, \$view, and \$scroll. Natural-language requests such as "show activity", "make a handoff", or "render this as a scroll" work too. Remaining mirrored workflows are adapter skills for long-tail coverage.
|
|
179
|
+
\$save is the user-facing abstraction for committing, pushing, opening or reusing pull requests, and syncing memory; do not make users manage the git workflow by hand.
|
|
180
|
+
Egregore Codex workflows are skill invocations, not Claude Code slash commands. Do not rely on Claude Code-only command machinery.
|
|
181
|
+
If onboarding_complete is false, use the memory protocol directly and make sure memory/people/${AUTHOR}.md exists before the first handoff.
|
|
182
|
+
EOF
|
|
183
|
+
;;
|
|
184
|
+
*)
|
|
185
|
+
echo "usage: bin/codex-session-start.sh [--card|--prompt]" >&2
|
|
186
|
+
exit 2
|
|
187
|
+
;;
|
|
188
|
+
esac
|