create-egregore 0.17.3 → 0.18.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.
Files changed (110) hide show
  1. package/assets/egregore-launcher.js +1965 -0
  2. package/assets/egregore-launcher.sh +385 -0
  3. package/bin/cli.js +472 -81
  4. package/lib/api.js +3 -3
  5. package/lib/auth.js +255 -20
  6. package/lib/codex-runtime.js +268 -0
  7. package/lib/commands.js +31 -0
  8. package/lib/context.js +1 -1
  9. package/lib/local.js +618 -193
  10. package/lib/setup.js +837 -85
  11. package/lib/ui.js +780 -84
  12. package/package.json +17 -4
  13. package/runtime/codex/.codex/config.toml +15 -0
  14. package/runtime/codex/.codex/hooks/branch-guard.js +234 -0
  15. package/runtime/codex/.codex/hooks.json +17 -0
  16. package/runtime/codex/.codex/skills/activity/SKILL.md +70 -0
  17. package/runtime/codex/.codex/skills/add/SKILL.md +25 -0
  18. package/runtime/codex/.codex/skills/announce/SKILL.md +54 -0
  19. package/runtime/codex/.codex/skills/answer/SKILL.md +25 -0
  20. package/runtime/codex/.codex/skills/archive/SKILL.md +41 -0
  21. package/runtime/codex/.codex/skills/ask/SKILL.md +59 -0
  22. package/runtime/codex/.codex/skills/branch/SKILL.md +25 -0
  23. package/runtime/codex/.codex/skills/checkup/SKILL.md +41 -0
  24. package/runtime/codex/.codex/skills/comment/SKILL.md +25 -0
  25. package/runtime/codex/.codex/skills/commit/SKILL.md +25 -0
  26. package/runtime/codex/.codex/skills/contribute/SKILL.md +25 -0
  27. package/runtime/codex/.codex/skills/dark-mode/SKILL.md +25 -0
  28. package/runtime/codex/.codex/skills/dashboard/SKILL.md +59 -0
  29. package/runtime/codex/.codex/skills/deep-reflect/SKILL.md +70 -0
  30. package/runtime/codex/.codex/skills/delete-user/SKILL.md +25 -0
  31. package/runtime/codex/.codex/skills/edit/SKILL.md +25 -0
  32. package/runtime/codex/.codex/skills/edit-process/SKILL.md +25 -0
  33. package/runtime/codex/.codex/skills/egregore-voice/SKILL.md +25 -0
  34. package/runtime/codex/.codex/skills/emissary/SKILL.md +41 -0
  35. package/runtime/codex/.codex/skills/env/SKILL.md +25 -0
  36. package/runtime/codex/.codex/skills/handoff/SKILL.md +67 -0
  37. package/runtime/codex/.codex/skills/harvest/SKILL.md +107 -0
  38. package/runtime/codex/.codex/skills/infra/SKILL.md +41 -0
  39. package/runtime/codex/.codex/skills/ingest/SKILL.md +25 -0
  40. package/runtime/codex/.codex/skills/ingest-google/SKILL.md +25 -0
  41. package/runtime/codex/.codex/skills/ingest-user-interview/SKILL.md +41 -0
  42. package/runtime/codex/.codex/skills/invite/SKILL.md +40 -0
  43. package/runtime/codex/.codex/skills/issue/SKILL.md +41 -0
  44. package/runtime/codex/.codex/skills/me/SKILL.md +25 -0
  45. package/runtime/codex/.codex/skills/meeting/SKILL.md +41 -0
  46. package/runtime/codex/.codex/skills/note/SKILL.md +25 -0
  47. package/runtime/codex/.codex/skills/onboarding/SKILL.md +41 -0
  48. package/runtime/codex/.codex/skills/pr/SKILL.md +25 -0
  49. package/runtime/codex/.codex/skills/project/SKILL.md +41 -0
  50. package/runtime/codex/.codex/skills/pull/SKILL.md +25 -0
  51. package/runtime/codex/.codex/skills/push/SKILL.md +25 -0
  52. package/runtime/codex/.codex/skills/quest/SKILL.md +77 -0
  53. package/runtime/codex/.codex/skills/quest-suggest/SKILL.md +25 -0
  54. package/runtime/codex/.codex/skills/reflect/SKILL.md +41 -0
  55. package/runtime/codex/.codex/skills/review-pr/SKILL.md +41 -0
  56. package/runtime/codex/.codex/skills/save/SKILL.md +62 -0
  57. package/runtime/codex/.codex/skills/setup/SKILL.md +25 -0
  58. package/runtime/codex/.codex/skills/summon/SKILL.md +41 -0
  59. package/runtime/codex/.codex/skills/sync-repos/SKILL.md +25 -0
  60. package/runtime/codex/.codex/skills/telegram-connect/SKILL.md +25 -0
  61. package/runtime/codex/.codex/skills/telemetry/SKILL.md +25 -0
  62. package/runtime/codex/.codex/skills/test/SKILL.md +41 -0
  63. package/runtime/codex/.codex/skills/the-spiral/SKILL.md +84 -0
  64. package/runtime/codex/.codex/skills/todo/SKILL.md +41 -0
  65. package/runtime/codex/.codex/skills/tui-design/SKILL.md +41 -0
  66. package/runtime/codex/.codex/skills/tutorial/SKILL.md +41 -0
  67. package/runtime/codex/.codex/skills/update/SKILL.md +25 -0
  68. package/runtime/codex/.codex/skills/view/SKILL.md +41 -0
  69. package/runtime/codex/.codex/skills/visual-explain/SKILL.md +41 -0
  70. package/runtime/codex/.codex/skills/wrap/SKILL.md +55 -0
  71. package/runtime/codex/.codex/spec-manifest.json +108 -0
  72. package/runtime/codex/AGENTS.md +328 -0
  73. package/runtime/codex/bin/activity-data.sh +180 -0
  74. package/runtime/codex/bin/agent.sh +669 -0
  75. package/runtime/codex/bin/codex-install-skills.sh +78 -0
  76. package/runtime/codex/bin/codex-render-spec.mjs +308 -0
  77. package/runtime/codex/bin/codex-session-start.sh +238 -0
  78. package/runtime/codex/bin/codex-skill-render.mjs +315 -0
  79. package/runtime/codex/bin/codex-sync-skills.sh +223 -0
  80. package/runtime/codex/bin/dashboard-data.sh +178 -0
  81. package/runtime/codex/bin/graph-batch.sh +60 -0
  82. package/runtime/codex/bin/graph-op.sh +397 -0
  83. package/runtime/codex/bin/graph-wal.sh +228 -0
  84. package/runtime/codex/bin/graph.sh +141 -0
  85. package/runtime/codex/bin/handoff-pr-backfill.sh +86 -0
  86. package/runtime/codex/bin/handoff-run.sh +569 -0
  87. package/runtime/codex/bin/handoff-save-egregore.sh +131 -0
  88. package/runtime/codex/bin/index-handoff.sh +306 -0
  89. package/runtime/codex/bin/lib/artifact-id.sh +46 -0
  90. package/runtime/codex/bin/lib/config.sh +71 -0
  91. package/runtime/codex/bin/lib/context.sh +511 -0
  92. package/runtime/codex/bin/lib/dashboard-artifact.sh +142 -0
  93. package/runtime/codex/bin/lib/edit-loopback.mjs +652 -0
  94. package/runtime/codex/bin/lib/ensure-develop.sh +183 -0
  95. package/runtime/codex/bin/lib/git-sync.sh +262 -0
  96. package/runtime/codex/bin/lib/greeting.sh +432 -0
  97. package/runtime/codex/bin/lib/hash.sh +13 -0
  98. package/runtime/codex/bin/lib/identity.sh +164 -0
  99. package/runtime/codex/bin/lib/permissions.sh +106 -0
  100. package/runtime/codex/bin/lib/time.sh +56 -0
  101. package/runtime/codex/bin/lib/worktree-links.sh +54 -0
  102. package/runtime/codex/bin/notify.sh +207 -0
  103. package/runtime/codex/bin/publish-artifact.sh +187 -0
  104. package/runtime/codex/bin/publish-references.sh +144 -0
  105. package/runtime/codex/bin/repo-state.sh +99 -0
  106. package/runtime/codex/bin/telemetry.sh +350 -0
  107. package/runtime/codex/bin/worktree-create.sh +115 -0
  108. package/runtime/codex/bin/worktree-remove.sh +50 -0
  109. package/runtime/codex/bin/worktree.sh +199 -0
  110. package/runtime/codex/manifest.json +162 -0
@@ -0,0 +1,328 @@
1
+ # Egregore Agent Protocol
2
+
3
+ Egregore is no longer only a Claude Code workspace. Claude Code remains the
4
+ first-class integrated runtime through `.claude/`, but any agent that can run
5
+ shell commands in this checkout can participate through the portable memory
6
+ protocol.
7
+
8
+ ## Startup
9
+
10
+ 1. Read `egregore.json` for the instance name, GitHub owner, and managed repos.
11
+ 2. Run `bin/agent.sh sync` to pull the latest shared memory.
12
+ 3. Read `memory/people/` to learn collaborator handles.
13
+ 4. Run `bin/agent.sh activity --for <your-handle>` to inspect handoffs and
14
+ pending questions addressed to you.
15
+ 5. Before code changes, use `bin/agent.sh branch --topic "<work topic>"`
16
+ when you need the runtime-neutral equivalent of Claude Code's worktree hook.
17
+ Continue work from the printed `worktree:` path.
18
+
19
+ ## Communication
20
+
21
+ Shell-level agents should use the runtime-neutral bridge instead of Claude Code
22
+ slash commands:
23
+
24
+ ```bash
25
+ bin/agent.sh branch --topic "auth review"
26
+ bin/agent.sh save --message "Save: auth review" --topic "auth review"
27
+ bin/agent.sh wrap --from alice --topic "auth review" \
28
+ --summary "Implemented the OAuth callback parser and documented follow-ups." \
29
+ --body "Open threads: review error cases and browser redirects."
30
+
31
+ bin/agent.sh handoff --from alice --to bob --topic "auth review" \
32
+ --body "Implemented the OAuth callback parser. Bob should review error cases."
33
+
34
+ bin/agent.sh ask --from bob --to alice --topic "auth review" \
35
+ --question "Should invalid state redirect to login or return 400?"
36
+
37
+ bin/agent.sh answer --from alice \
38
+ --question memory/knowledge/questions/2026-04-26-bob-to-alice-auth-review.md \
39
+ --body "Return 400 in the API path; redirect only in browser routes."
40
+ ```
41
+
42
+ Each command writes to the existing Git-backed `memory/` repository and pushes
43
+ when the memory repo has an `origin` remote. Agents that cannot run shell may
44
+ write the same markdown files directly, following `docs/AGENT-PROTOCOL.md`.
45
+
46
+ ## Handoffs vs Emissaries
47
+
48
+ `bin/agent.sh handoff` is the runtime-neutral path for internal team
49
+ session-handoffs: it writes to `memory/handoffs/`, updates the index, and uses
50
+ the same `bin/handoff-run.sh` machinery as Claude Code's `/handoff`.
51
+
52
+ Portable external capsules are **emissaries**, not team handoffs. Claude Code
53
+ routes those through `/emissary`; non-Claude agents should use the
54
+ `egregore-emissary` CLI/skill when it is installed. Do not use the deprecated
55
+ `egregore-handoff` CLI for Egregore project `/handoff` work.
56
+
57
+ ## Compatibility
58
+
59
+ Claude Code and Codex users can use Egregore slash workflows such as
60
+ `/handoff`, `/activity`, `/ask`, and `/save`. Shell-only agents should use
61
+ `bin/agent.sh` and the file protocol. Both paths converge on the same
62
+ `memory/` files.
63
+
64
+ <!-- BEGIN GENERATED EGREGORE CODEX SPEC — derived from CLAUDE.md by bin/codex-render-spec.mjs; do not edit by hand -->
65
+
66
+ ## Egregore on Codex
67
+
68
+ 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.
69
+
70
+ 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.
71
+
72
+ ---
73
+
74
+ ## Identity & Upstream
75
+
76
+ This is an Egregore instance — a downstream fork of the upstream framework at `egregore-labs/egregore`. The framework (`bin/`, `.claude/skills/`, `.claude/hooks/`, `.claude/context/`, `CLAUDE.md`, `skills/`) is synced from upstream on every session start and via `$update`. It is not authored in this repo.
77
+
78
+ **Where changes belong:**
79
+ - **Framework is outdated or a skill is missing:** run `$update` first. It pulls the latest from upstream.
80
+ - **Framework behavior needs changing or has a bug:** `$contribute` opens a PR against `egregore-labs/egregore`, or file a GitHub issue on that repo. Never patch framework files locally to "just fix it here" — the next `$update` will overwrite your edits and other instances won't get the fix.
81
+ - **Org-level work** (memory, org-specific knowledge, managed repos, `egregore.json`): `$save` to this repo.
82
+
83
+ When a user reports broken or missing framework behavior, the first question is "when did you last `$update`?"
84
+
85
+ ---
86
+
87
+ ## On Launch — MANDATORY FIRST ACTION
88
+
89
+ The `egregore` launcher renders the Egregore startup card (identity, handoffs, team activity) 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`.
90
+
91
+ ---
92
+
93
+ ## After Greeting — BRANCH ON FIRST RESPONSE
94
+
95
+ **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:
96
+
97
+ 1. Derive a topic slug from what the user said (kebab-case, 2–4 words)
98
+ 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.
99
+ 3. Confirm: `On {branch} (worktree).`
100
+
101
+ **Fallback:** If `bin/agent.sh branch` fails, use `git checkout -b dev/{author}/{slug} origin/develop`.
102
+
103
+ 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 &`
104
+
105
+ ### Handoff claiming
106
+
107
+ If `addressed_to_user` handoffs exist and the user is picking one up, create the IMPLEMENTS link after branch creation:
108
+ ```bash
109
+ bash bin/graph-op.sh claim-handoff "$SESSION_ID" "$HANDOFF_SESSION_ID" 2>/dev/null &
110
+ ```
111
+
112
+ **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:
113
+
114
+ ```bash
115
+ PARENT_DIR="$(cd .. && pwd)"
116
+ # For each entry in repoState:
117
+ REPO_DIR="$PARENT_DIR/$REPO_NAME"
118
+ if [ -d "$REPO_DIR/.git" ] || [ -f "$REPO_DIR/.git" ]; then
119
+ git -C "$REPO_DIR" fetch origin "$BRANCH" --quiet 2>/dev/null
120
+ git -C "$REPO_DIR" checkout "$BRANCH" 2>/dev/null || \
121
+ git -C "$REPO_DIR" checkout -b "$BRANCH" "origin/$BRANCH" 2>/dev/null
122
+ fi
123
+ ```
124
+
125
+ 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.
126
+
127
+ **Exceptions** — skip branching when:
128
+ - The user explicitly created or named a branch themselves
129
+ - Already on a working branch AND the user's intent continues the current branch's topic
130
+
131
+ **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.
132
+
133
+ If on develop after two messages, create a branch immediately from whatever context you have.
134
+
135
+ ### Branch-guard protocol
136
+
137
+ 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:
138
+
139
+ - **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.
140
+ - **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):
141
+
142
+ ```text
143
+ Need a working branch first. Topic?
144
+ 1. <suggested slug from context>
145
+ 2. <alternative slug>
146
+ 3. Other: (name it)
147
+ ```
148
+
149
+ Wait for the reply, then branch.
150
+
151
+ If this Codex build does not support hooks, follow the same discipline as a standing instruction: never write or commit on develop/main/master.
152
+
153
+ ### Onboarding exception
154
+
155
+ If the startup card output contains `onboarding_needed`, invoke the `$onboarding` skill instead of greeting.
156
+
157
+ ---
158
+
159
+ ## Config Files
160
+
161
+ - **`egregore.json`** — committed. Non-secret org config: `org_name`, `github_org`, `memory_repo`, `slug`, `mode`. `api_url` is connected-mode only. **Never put secrets here.**
162
+ - **`.env`** — gitignored. Personal secrets. Local mode: `GITHUB_TOKEN` only. Connected mode: `GITHUB_TOKEN` + `EGREGORE_API_KEY`. **Never use `source .env`** — use `grep '^KEY=' .env | cut -d'=' -f2-`.
163
+
164
+ In connected mode, infrastructure credentials (Neo4j, Telegram) live on the API server only — `bin/graph.sh` and `bin/notify.sh` route through the API gateway.
165
+
166
+ ---
167
+
168
+ ## Knowledge Graph
169
+
170
+ **Connected mode only.** Always use `bin/graph.sh` for Neo4j queries — never construct curl calls directly. See DEVELOPMENT.md §1 for usage examples and current schema. In local mode there is no graph; read `memory/` directly.
171
+
172
+ ---
173
+
174
+ ## Notifications
175
+
176
+ **Connected mode only.** Always use `bin/notify.sh` for Telegram notifications — never construct API calls directly. See DEVELOPMENT.md §1 for usage examples. In local mode there are no live notifications.
177
+
178
+ ---
179
+
180
+ ---
181
+
182
+ ## Onboarding
183
+
184
+ When `onboarding_complete` is false in `.egregore-state.json`, invoke `$onboarding`. The command is the single source of truth — do NOT run steps inline.
185
+
186
+ ---
187
+
188
+ ## Transparency Beat
189
+
190
+ After the first silent bash command in any session, mention once:
191
+
192
+ > I run commands directly to keep things fast — you can see everything in the session log, and change permissions in `.claude/settings.json` anytime.
193
+
194
+ Never repeat it.
195
+
196
+ ---
197
+
198
+ ## Memory
199
+
200
+ `memory/` is a symlink to the memory repo defined in `egregore.json`. Key directories:
201
+ - `people/` — team directory
202
+ - `handoffs/` — session handoffs + `index.md`
203
+ - `knowledge/decisions/` — org decisions
204
+ - `knowledge/patterns/` — emergent patterns
205
+ - `infrastructure/` — service registry (URLs, names, credential locations)
206
+
207
+ Always use HTTPS for git operations — `github-auth.sh` handles credential storage.
208
+
209
+ ---
210
+
211
+ ## Git Workflow
212
+
213
+ `develop` branch model with deferred, topic-based branching. Users never interact with git directly.
214
+
215
+ ```
216
+ main ← stable (/release)
217
+ develop ← integration (PRs land here)
218
+ dev/{author}/{topic-slug} | feature/{slug} | bugfix/{slug}
219
+ ```
220
+
221
+ - **On launch**: syncs develop + memory. Does NOT create a branch.
222
+ - **Branch creation**: MANDATORY on first work-related message (see above).
223
+ - **Resuming**: rebase onto develop and continue.
224
+ - **If on develop after two messages**: create branch immediately.
225
+ - **`$save`**: pushes working branch, PR to develop. Auto-merges markdown-only PRs.
226
+ - **Memory repo**: stays on main (separate repo, auto-merge).
227
+ - **Never push directly to main or develop.** All changes flow through PRs.
228
+
229
+ ### Managed Repos
230
+
231
+ Repos in `egregore.json` → `repos[]` are cloned as siblings (`../{repo}/`). Each entry can be a string or `{"name": "...", "description": "..."}`. Match user intent to the right repo using `description`. Same branching strategy. Use `git -C` with absolute paths — never `cd` into repos. `$save` scans all managed repos for uncommitted changes.
232
+
233
+ ---
234
+
235
+ ## Working Conventions
236
+
237
+ - Check `memory/knowledge/` before starting unfamiliar work
238
+ - Document significant decisions in `memory/knowledge/decisions/`
239
+ - After substantial sessions, log to `memory/handoffs/` and update `index.md`
240
+
241
+ ---
242
+
243
+ ## Command Awareness
244
+
245
+ 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`. 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.
246
+
247
+ Invoke commands from user intent — don't wait for the slash. Each command file has a `## When to invoke` section. Load it for the full spec.
248
+
249
+ **Core loop** — `$activity` `$dashboard` `$handoff` `$wrap` `$save` `$reflect` `$todo`
250
+ **Knowledge** — `$deep-reflect` `$archive` `$note` `$add` `$meeting` `$ingest`
251
+ **Identity** — `$me` (view profile or set display name)
252
+ **Coordination** — `$ask` `$quest` `$issue` `$invite` `$delete-user` `$announce`
253
+ **Connectors** — `$telegram-connect` (Telegram group setup)
254
+ **Git** — `$branch` `$commit` `$push` `$pr` `$save` `$review-pr` `$contribute`
255
+ **Spirits** — `$summon` (persistent agent processes)
256
+ **Infra** — `$setup` `$update` `$pull` `$env` `$infra` `$sync-repos` `$release` `$checkup`
257
+
258
+ **Disambiguation:**
259
+ - Knowledge: `$reflect` (share-ready) · `$note` (half-baked) · `$deep-reflect` (cross-reference) · `$archive` (AI patterns)
260
+ - Status: `$dashboard` (personal) · `$activity` (org-wide)
261
+ - Ending: `$wrap` (personal closure) · `$handoff` (notes for others) · `$save` (still working)
262
+ - Tasks: `$todo` (personal) · `$quest` (team exploration) · `$issue` (something broken)
263
+ - Questions: `$ask [person]` (async) · just ask (agent answers from context)
264
+ - Ingestion: `$ingest meeting` · `$ingest user-interview` · `$ingest google` · ambiguous → ask which type
265
+ - Connectors: `$telegram-connect` (Telegram group) · `$ingest` (bring content in)
266
+ - Identity: `$me` — "who am I", "call me oz"
267
+ - People: `$invite` (add) · `$delete-user` (remove)
268
+ - PRs: `$pr` (create) · `$review-pr` (review)
269
+ - Contributing: `$contribute` (upstream framework) · `$save` (org repo) · `$issue` (report bug)
270
+ - Agents: `$summon` (design through questions) · `/loop` (quick recurring schedule)
271
+ - Announcements: `$announce` (broadcast to group) · `$handoff` (structured to a person) · `bin/notify.sh send` (DM one person)
272
+
273
+ ---
274
+
275
+ ## Socratic Questioning (MANDATORY)
276
+
277
+ **Triggers**: "ask me questions", "question me", "help me think through", or any request to be questioned.
278
+
279
+ 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`.
280
+
281
+ **Rules:** Max 4 questions per batch. When choices aren't mutually exclusive, say "pick any that apply".
282
+
283
+ ---
284
+
285
+ ## Telemetry
286
+
287
+ Privacy-respecting, opt-out telemetry. After every slash command, emit fire-and-forget:
288
+ `bash bin/telemetry.sh emit "command" '{"command":"save"}' 2>/dev/null &`
289
+
290
+ Never collected: file contents, code, env var values, conversation content.
291
+ On first session (if `telemetry_noticed` not set in state file), mention the notice once, then set `telemetry_noticed: true`. Full spec: `.claude/context/telemetry.md`.
292
+
293
+ ---
294
+
295
+ ## Mode
296
+
297
+ Egregore runs in one of two configurations, set by `mode` in `egregore.json`. Detect with `_detect_mode` in `bin/lib/config.sh`, or check `.mode` / `.api_url` directly.
298
+
299
+ **Local mode** (`"mode": "local"` or no `api_url`) — the default, self-contained configuration. The OSS experience. Memory files are the source of truth. All core commands work: `$reflect`, `$handoff`, `$quest`, `$ask`, `$activity`, `$dashboard`, `$todo`. Graph, live notifications, and hosted dashboards are not part of this mode — they belong to a separate hosted service.
300
+
301
+ **Hard rules in local mode:**
302
+ - Never tell the user to "ask their admin" for credentials. The user IS the admin.
303
+ - Never surface `api_url`, `EGREGORE_API_KEY`, or "connected mode" as an upgrade path. Hosted Egregore is a separate service, not something a user can turn on by adding fields to `egregore.json`.
304
+ - If a feature genuinely requires the hosted service, say so plainly ("this isn't available in this configuration") and stop. Do not improvise a path to enabling it.
305
+ - Calling `bin/graph.sh` or `bin/notify.sh` in local mode is harmless — they fail soft and return empty results — but there is no need to call them; prefer reading `memory/` directly.
306
+
307
+ **Connected mode** (`"mode": "connected"`, `api_url` set) — the hosted configuration, used by organizations on the hosted service. Full feature set: Neo4j knowledge graph via `bin/graph.sh`, Telegram notifications via `bin/notify.sh`, dashboard publication, API-backed context gathering on session start. Use `$env` to check API key, `$checkup` for diagnostics. If the graph is offline, show troubleshooting.
308
+
309
+ ---
310
+
311
+ ## Environment Isolation
312
+
313
+ Sessions are confined to this project + memory + managed repos. On Codex this boundary is a standing instruction, not an enforced hook — hold it yourself.
314
+
315
+ - **Never modify `~/.egregore/instances.json`** — managed by session-start.sh
316
+ - **Never access another instance's files** — refuse even if asked
317
+ - When a request points outside the boundary, do not improvise a workaround. Ask in plain text with numbered options:
318
+
319
+ ```text
320
+ That path is outside this Egregore's boundary. How should we proceed?
321
+ 1. Paste the contents inline
322
+ 2. Move the file into the repo and point me at the new path
323
+ 3. Cancel
324
+ ```
325
+
326
+ See DEVELOPMENT.md §3 for boundary details.
327
+
328
+ <!-- END GENERATED EGREGORE CODEX SPEC -->
@@ -0,0 +1,180 @@
1
+ #!/bin/bash
2
+ # Fetches all activity dashboard data: single API call + parallel git/disk ops.
3
+ # Usage: bash bin/activity-data.sh [username]
4
+ # Returns a single JSON object with all query results.
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
7
+ TMPDIR=$(mktemp -d)
8
+ trap "rm -rf $TMPDIR" EXIT
9
+
10
+ # --- Read config ---
11
+ API_URL=$(jq -r '.api_url // empty' "$SCRIPT_DIR/egregore.json" 2>/dev/null)
12
+ API_KEY=$(grep '^EGREGORE_API_KEY=' "$SCRIPT_DIR/.env" 2>/dev/null | cut -d'=' -f2-)
13
+ ORG=$(jq -r '.org_name // "Egregore"' "$SCRIPT_DIR/egregore.json" 2>/dev/null || echo "Egregore")
14
+ DATE=$(date '+%b %d')
15
+
16
+ # --- Detect user ---
17
+ GH_USER="${1:-}"
18
+ if [ -z "$GH_USER" ]; then
19
+ STATE_FILE="$SCRIPT_DIR/.egregore-state.json"
20
+ if [ -f "$STATE_FILE" ]; then
21
+ GH_USER=$(jq -r '.github_username // empty' "$STATE_FILE" 2>/dev/null)
22
+ fi
23
+ if [ -z "$GH_USER" ]; then
24
+ GH_USER=$(git -C "$SCRIPT_DIR" config user.name 2>/dev/null || echo "unknown")
25
+ fi
26
+ fi
27
+
28
+ EMPTY='{"fields":[],"values":[]}'
29
+
30
+ # --- Fire API call + git/disk ops in parallel ---
31
+
32
+ # Graph data: single API call (all queries run server-side)
33
+ (
34
+ GRAPH_STATUS="offline"
35
+ GRAPH_REASON=""
36
+ if [ -z "$API_URL" ] || [ -z "$API_KEY" ]; then
37
+ GRAPH_REASON="missing_config"
38
+ else
39
+ # Store HTTP status code alongside response body. curl already emits 000
40
+ # on transport failure; keep the exit status separate so it cannot become
41
+ # 000000 and fall through as an invalid JSON response.
42
+ CURL_STATUS=0
43
+ HTTP_CODE=$(curl -s -o "$TMPDIR/activity_raw.json" -w "%{http_code}" \
44
+ "${API_URL}/api/activity/dashboard?github_username=$(printf '%s' "$GH_USER" | jq -sRr @uri)" \
45
+ -H "Authorization: Bearer $API_KEY" \
46
+ --connect-timeout 5 --max-time 15 2>/dev/null) || CURL_STATUS=$?
47
+
48
+ if [ "$CURL_STATUS" -ne 0 ] || [ "$HTTP_CODE" = "000" ] || ! [[ "$HTTP_CODE" =~ ^[0-9][0-9][0-9]$ ]]; then
49
+ GRAPH_REASON="unreachable"
50
+ elif [ "$HTTP_CODE" = "401" ] || [ "$HTTP_CODE" = "403" ]; then
51
+ GRAPH_REASON="auth_error"
52
+ elif [ "$HTTP_CODE" -ge 500 ] 2>/dev/null; then
53
+ GRAPH_REASON="server_error"
54
+ elif [ -s "$TMPDIR/activity_raw.json" ] && jq -e '.me' "$TMPDIR/activity_raw.json" >/dev/null 2>&1; then
55
+ cp "$TMPDIR/activity_raw.json" "$TMPDIR/activity.json"
56
+ GRAPH_STATUS="connected"
57
+ else
58
+ GRAPH_REASON="invalid_response"
59
+ fi
60
+ fi
61
+
62
+ # If not connected, write status-only response
63
+ if [ "$GRAPH_STATUS" != "connected" ]; then
64
+ jq -n --arg status "$GRAPH_STATUS" --arg reason "$GRAPH_REASON" \
65
+ '{graph_status: $status, graph_reason: $reason}' > "$TMPDIR/activity.json"
66
+ else
67
+ # Inject graph_status into successful response
68
+ jq --arg status "$GRAPH_STATUS" '. + {graph_status: $status}' \
69
+ "$TMPDIR/activity.json" > "$TMPDIR/activity_merged.json" \
70
+ && mv "$TMPDIR/activity_merged.json" "$TMPDIR/activity.json"
71
+ fi
72
+ ) &
73
+ API_PID=$!
74
+
75
+ # Git/disk: runs in parallel (stays client-side)
76
+ (
77
+ # Sync
78
+ git -C "$SCRIPT_DIR" fetch origin --quiet 2>/dev/null || true
79
+ CURRENT=$(git -C "$SCRIPT_DIR" branch --show-current 2>/dev/null || echo "unknown")
80
+ if [ "$CURRENT" != "develop" ]; then
81
+ git -C "$SCRIPT_DIR" fetch origin develop:develop --quiet 2>/dev/null || true
82
+ fi
83
+ if [[ "$CURRENT" == dev/* ]]; then
84
+ git -C "$SCRIPT_DIR" rebase develop --quiet >/dev/null 2>&1 || git -C "$SCRIPT_DIR" rebase --abort >/dev/null 2>&1 || true
85
+ fi
86
+
87
+ # Memory sync
88
+ if [ -d "$SCRIPT_DIR/memory/.git" ] || [ -L "$SCRIPT_DIR/memory" ]; then
89
+ git -C "$SCRIPT_DIR/memory" fetch origin main --quiet 2>/dev/null || true
90
+ LOCAL=$(git -C "$SCRIPT_DIR/memory" rev-parse HEAD 2>/dev/null || echo "")
91
+ REMOTE=$(git -C "$SCRIPT_DIR/memory" rev-parse origin/main 2>/dev/null || echo "")
92
+ if [ -n "$LOCAL" ] && [ -n "$REMOTE" ] && [ "$LOCAL" != "$REMOTE" ]; then
93
+ git -C "$SCRIPT_DIR/memory" pull origin main --quiet 2>/dev/null || true
94
+ fi
95
+ fi
96
+
97
+ # PRs
98
+ PRS=$(cd "$SCRIPT_DIR" && gh pr list --base develop --state open --json number,title,author 2>/dev/null || echo "[]")
99
+ echo "$PRS" > "$TMPDIR/prs.json"
100
+
101
+ # Disk cross-reference
102
+ MONTH=$(date +%Y-%m)
103
+ TODAY=$(date +%d)
104
+ YESTERDAY=$(date -v-1d +%d 2>/dev/null || date -d 'yesterday' +%d 2>/dev/null || echo "00")
105
+ HANDOFFS=$(ls -1 "$SCRIPT_DIR/memory/handoffs/$MONTH/" 2>/dev/null | grep "^${TODAY}-\|^${YESTERDAY}-" 2>/dev/null | head -10 || echo "")
106
+ echo "$HANDOFFS" > "$TMPDIR/disk_handoffs.txt"
107
+
108
+ DECISIONS=$(ls -1t "$SCRIPT_DIR/memory/knowledge/decisions/" 2>/dev/null | head -5 || echo "")
109
+ echo "$DECISIONS" > "$TMPDIR/disk_decisions.txt"
110
+ ) &
111
+ GIT_PID=$!
112
+
113
+ # Local sessions: parse memory files when graph is offline (parallel)
114
+ (
115
+ GH_LC=$(echo "$GH_USER" | tr '[:upper:]' '[:lower:]')
116
+ DISPLAY_LC=""
117
+ if [ -f "$SCRIPT_DIR/.egregore-state.json" ]; then
118
+ DISPLAY_LC=$(jq -r '.display_name // empty' "$SCRIPT_DIR/.egregore-state.json" 2>/dev/null | tr '[:upper:]' '[:lower:]')
119
+ fi
120
+
121
+ CUTOFF=$(date -v-14d +%Y-%m-%d 2>/dev/null || date -d '14 days ago' +%Y-%m-%d 2>/dev/null || echo "2000-01-01")
122
+ MY="[]"
123
+ TEAM="[]"
124
+
125
+ # Scan sessions, wraps, and handoffs
126
+ ALL_ENTRIES=""
127
+ for DIR in "$SCRIPT_DIR/memory/sessions" "$SCRIPT_DIR/memory/wraps" "$SCRIPT_DIR/memory/handoffs"; do
128
+ [ -d "$DIR" ] || continue
129
+ TYPE=$(basename "$DIR")
130
+ find -L "$DIR" -name '*.md' -not -name 'index*' -type f 2>/dev/null | xargs ls -t 2>/dev/null | head -20 | while read -r MFILE; do
131
+ [ -z "$MFILE" ] && continue
132
+ M_AUTH=$(head -10 "$MFILE" 2>/dev/null | grep -m1 '^\*\*Author\*\*:' | sed 's/^\*\*Author\*\*:[[:space:]]*//')
133
+ M_DATE=$(head -10 "$MFILE" 2>/dev/null | grep -m1 '^\*\*Date\*\*:' | sed 's/^\*\*Date\*\*:[[:space:]]*//')
134
+ M_BRANCH=$(head -10 "$MFILE" 2>/dev/null | grep -m1 '^\*\*Branch\*\*:' | sed 's/^\*\*Branch\*\*:[[:space:]]*//')
135
+ M_DURATION=$(head -10 "$MFILE" 2>/dev/null | grep -m1 '^\*\*Duration\*\*:' | sed 's/^\*\*Duration\*\*:[[:space:]]*//')
136
+ M_TOPIC=$(head -3 "$MFILE" 2>/dev/null | grep -m1 '^# ' | sed 's/^# [^:]*:[[:space:]]*//')
137
+ [ -z "$M_AUTH" ] && continue
138
+ # Date filter
139
+ M_DAY="${M_DATE%%T*}"
140
+ [ -n "$M_DAY" ] && [ "$M_DAY" \< "$CUTOFF" ] && continue
141
+ echo "${M_AUTH}|${M_DATE}|${M_BRANCH}|${M_TOPIC}|${M_DURATION}|${TYPE}"
142
+ done
143
+ done | jq -Rn --arg gh "$GH_LC" --arg dn "$DISPLAY_LC" '
144
+ [inputs | split("|") |
145
+ {author: .[0], date: .[1], branch: .[2], topic: .[3], duration: .[4], type: .[5]}
146
+ ] | {
147
+ my_sessions: [.[] | select((.author | ascii_downcase) == $gh or (.author | ascii_downcase) == $dn) | select($dn != "" or (.author | ascii_downcase) == $gh)],
148
+ team_sessions: [.[] | select((.author | ascii_downcase) != $gh and (if $dn != "" then (.author | ascii_downcase) != $dn else true end))]
149
+ }
150
+ ' 2>/dev/null > "$TMPDIR/local_sessions.json" || echo '{"my_sessions":[],"team_sessions":[]}' > "$TMPDIR/local_sessions.json"
151
+ ) &
152
+ LOCAL_PID=$!
153
+
154
+ # --- Wait for all ---
155
+ wait $API_PID $GIT_PID $LOCAL_PID 2>/dev/null || true
156
+
157
+ # --- Read results ---
158
+ PRS=$(cat "$TMPDIR/prs.json" 2>/dev/null || echo "[]")
159
+ echo "$PRS" | jq . >/dev/null 2>&1 || PRS="[]"
160
+ DISK_HANDOFFS=$(cat "$TMPDIR/disk_handoffs.txt" 2>/dev/null || echo "")
161
+ DISK_DECISIONS=$(cat "$TMPDIR/disk_decisions.txt" 2>/dev/null || echo "")
162
+ LOCAL_SESSIONS=$(cat "$TMPDIR/local_sessions.json" 2>/dev/null || echo '{"my_sessions":[],"team_sessions":[]}')
163
+ echo "$LOCAL_SESSIONS" | jq . >/dev/null 2>&1 || LOCAL_SESSIONS='{"my_sessions":[],"team_sessions":[]}'
164
+
165
+ # --- Merge server response + local git/disk data ---
166
+ jq -n \
167
+ --arg org "$ORG" \
168
+ --arg date "$DATE" \
169
+ --slurpfile activity "$TMPDIR/activity.json" \
170
+ --argjson prs "$PRS" \
171
+ --arg disk_handoffs "$DISK_HANDOFFS" \
172
+ --arg disk_decisions "$DISK_DECISIONS" \
173
+ --argjson local_sessions "$LOCAL_SESSIONS" \
174
+ '$activity[0] + {
175
+ org: $org,
176
+ date: $date,
177
+ prs: $prs,
178
+ disk: {handoffs: $disk_handoffs, decisions: $disk_decisions},
179
+ local_sessions: $local_sessions
180
+ }'