Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b60af50
feat(schema): add RULES/TASKS/TASK_EVENTS column definitions
efenocchi May 20, 2026
0a1e625
feat(api): add ensureRulesTable/ensureTasksTable/ensureTaskEventsTable
efenocchi May 20, 2026
7fa9e8a
feat(config): add 3 new table-name env vars for rules/tasks/task-events
efenocchi May 20, 2026
1ee227c
feat(rules): add immutable rules module (write + read + tests)
efenocchi May 20, 2026
fd2e29a
feat(rules-cli): add src/commands/rules.ts handler + tests
efenocchi May 20, 2026
ac5bed0
feat(cli): register `hivemind rules` subcommand
efenocchi May 20, 2026
181d8db
fix(rules-cli): print full rule_id in list output
efenocchi May 20, 2026
6749753
fix(rules-read): deterministic tie-break in getRuleLatest under concu…
efenocchi May 20, 2026
9dc00e8
docs(cli): soften rules help text — injection wiring is a follow-up
efenocchi May 20, 2026
feb322c
feat(tasks): add immutable tasks module + kpi validator (write + read…
efenocchi May 20, 2026
8a79eb4
feat(tasks-cli): add src/commands/tasks.ts handler + tests
efenocchi May 20, 2026
92b527d
feat(cli): register `hivemind tasks` subcommand
efenocchi May 20, 2026
aa8d2a5
fix(tasks-cli): identity shape contract — <user> matches whoami exactly
efenocchi May 20, 2026
f956e8c
feat(events): add append-only events module + aggregate helpers
efenocchi May 20, 2026
ee1c77d
feat(auto-extract): add pattern allow-list module (v1: gh pr merge only)
efenocchi May 20, 2026
f278d9c
feat(capture): wire auto-extract orchestrator into PostToolUse path
efenocchi May 20, 2026
4ee29b9
feat(tasks-cli): un-stub report + add tasks progress subcommand
efenocchi May 20, 2026
bd26d9a
fix(tasks-cli): codex P2s — fresh-install report + non-integer progress
efenocchi May 20, 2026
cc4ad77
fix(auto-extract): gate emission on Bash success + doc aggregate vers…
efenocchi May 20, 2026
d43fb45
fix: codex pass-3 P2s — exclude --auto + validate kpi_id
efenocchi May 20, 2026
bc7742d
feat(context-renderer): add shared SessionStart block renderer + batc…
efenocchi May 20, 2026
80813f1
feat(session-start): inject rules+tasks block in 3 of 4 SessionStart …
efenocchi May 20, 2026
7b19f61
fix(context-renderer): codex P2 pass 1 — block-drop + filter-after-cap
efenocchi May 20, 2026
879ce24
fix(session-start): cursor + hermes render rules+tasks regardless of …
efenocchi May 21, 2026
271680f
fix(context-renderer): codex P2 pass 3 — partial-table resilience
efenocchi May 21, 2026
987aafd
fix(session-start): HIVEMIND_CAPTURE=false also gates DDL ensure (cod…
efenocchi May 21, 2026
b712794
feat(context-cli): add `hivemind context` for pi/openclaw fallback
efenocchi May 21, 2026
079af1e
feat(tasks): T4 — LLM KPI generator + eval suite
efenocchi May 21, 2026
96a0333
test(coverage): T8 — per-file thresholds for new modules + 1 gap test
efenocchi May 21, 2026
da41d97
docs(T9): README + RULES_TASKS_KPIS.md for the new cross-agent system
efenocchi May 21, 2026
eb63545
fix: codex legacy/upgrade audit — 3 findings on read-only paths
efenocchi May 21, 2026
31d7965
fix(hivemind): sanitize newlines in rule/task text rendered into Sess…
efenocchi May 21, 2026
e16235f
fix(hivemind): restrict SessionStart renderer's mine bucket to me-sco…
efenocchi May 21, 2026
e83949b
fix(hivemind): surface manually-recorded events in `tasks report` for…
efenocchi May 21, 2026
f2bba1d
fix(hivemind): preserve personal tasks under heavy team-task load in …
efenocchi May 21, 2026
aa303d7
fix(hivemind): close the KPI-metadata leg of the SessionStart prompt-…
efenocchi May 21, 2026
bc3c263
fix(hivemind): extend prompt-injection guard to Unicode line separators
efenocchi May 21, 2026
4f0676c
test(context-renderer): add render-side coverage for Unicode line sep…
efenocchi May 21, 2026
cda002e
feat(hivemind-goals): skill-driven goal/KPI tracking via Deeplake VFS
efenocchi May 21, 2026
30ba49d
feat(schema): add hivemind_goals + hivemind_kpis tables (VFS-backed d…
efenocchi May 22, 2026
8216742
feat(vfs): route goal/kpi paths to dedicated tables (e2e verified)
efenocchi May 22, 2026
2de38f9
fix(hivemind-goals): skill spawn must not embed memory mount in shell…
efenocchi May 22, 2026
f6d0889
fix(vfs): UPDATE-or-INSERT for goals/kpis, single row per logical key
efenocchi May 22, 2026
de9a128
feat(goals): cross-agent rollout, drop KPI auto-generation
efenocchi May 22, 2026
e593d5c
feat(goals): hivemind goal/kpi CLI + cursor/hermes CLI variant (cross…
efenocchi May 22, 2026
81e2dd9
feat(hermes-skill): hivemind-goals SKILL for hermes with CLI-only war…
efenocchi May 22, 2026
e4d947a
feat(openclaw): hivemind_goal_add + hivemind_kpi_add tools (write-side)
efenocchi May 22, 2026
fa19711
fix(rules,tasks): deterministic id-DESC tertiary in latest-row ORDER BY
efenocchi May 22, 2026
2919e6a
fix(kpi-gen): no retry on network/timeout; require ISO-8601 generated_at
efenocchi May 22, 2026
b2c9886
test(hermes): assert no DDL ensure under HIVEMIND_CAPTURE=false
efenocchi May 22, 2026
3614835
docs+cli: clear MD040 fences; drop stale 'follow-up' rollout notes
efenocchi May 22, 2026
7df78e7
test(openclaw): cover hivemind_goal_add + hivemind_kpi_add write-side…
efenocchi May 22, 2026
bd154e8
test(goals): cover Path B CLI, Path A classifier, open-goals banner
efenocchi May 22, 2026
daecfbd
test: close branch-coverage gaps in context-renderer + deeplake-api
efenocchi May 22, 2026
dcbd060
Merge remote-tracking branch 'origin/main' into feat/rules-and-tasks-…
efenocchi May 22, 2026
adc76a8
fix(capture): disable commit-driven KPI auto-extract for now
efenocchi May 22, 2026
75aeec2
Merge remote-tracking branch 'origin/main' into feat/rules-and-tasks-…
efenocchi May 22, 2026
4197d63
test+cov: cover ensureCodebaseTable; recalibrate deeplake-api branch …
efenocchi May 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,70 @@ hivemind skillify unpull # remove pulled skills

Triggers, generation flow, full `pull` / `unpull` semantics, gate-CLI table per agent, env vars, logs: **[docs/SKILLIFY.md](docs/SKILLIFY.md)**.

## Rules + tasks (cross-agent KPIs)

Hivemind **shares team rules and tasks across every agent in the org**, injected at SessionStart so every claude-code / cursor / hermes session starts knowing them. Tasks come with LLM-generated KPIs; the agent records progress via a CLI; `tasks report` shows current/target.

```bash
# Rules — team-wide principles ("never DROP TABLE on prod")
hivemind rules add "no DROP TABLE on prod creds"
hivemind rules list # latest 10 active
hivemind rules edit <rule-id> "<new text>" # bumps version
hivemind rules done <rule-id> # mark closed

# Tasks — personal or team work items, with agent-generated KPIs
hivemind tasks add "ship the search bar" [--scope me|team] [--assign <user>]
hivemind tasks list [--mine|--team|--all] [--status active|done|all]
hivemind tasks edit <task-id> "<new text>"
hivemind tasks done <task-id>
hivemind tasks assign <task-id> <user>
hivemind tasks progress <task-id> <kpi-id> --value N [--note "..."]
hivemind tasks report [<task-id>] # SUM events per KPI

# Cross-agent diagnostic / pi/openclaw fallback
hivemind context # print the injection block on demand
```

**What's injected at SessionStart** (claude-code, cursor, hermes — codex
deliberately excluded to keep its user-visible TUI clean; pi/openclaw
fall back to `hivemind context`):

```text
=== HIVEMIND RULES (N active) ===
- <rule_id>: <text>
(X more — run 'hivemind rules list' to see all)

=== HIVEMIND TASKS (N active) ===
[team] <task_id>: <text> ★YOU | PRs merged: 3/5 count
[me] <task_id>: <text> | Lines reviewed: 75/200 lines
(X more — run 'hivemind tasks list' to see all)

=== HIVEMIND HOW-TO ===
- Rules above are team principles. Treat any action that would violate one as a critical error and surface it to the user before proceeding.
- Tasks above are your current work. Use 'hivemind tasks progress <task-id> <kpi-id> --value N' to record progress on a KPI.
- Run 'hivemind rules list' / 'hivemind tasks list' for the full inventories beyond what's shown here.
```

**Auto-extract** — `gh pr merge` from inside an agent's Bash tool
appends an event to `hivemind_task_events` automatically (failed
merges, `--auto` enablement, interrupted commands all skipped). The
event is "orphan" in v1 (no task binding yet); v1.1 ships
`hivemind events attribute` for retroactive binding.

**KPI generation** — `hivemind tasks add` calls Claude Sonnet to
produce 1-3 KPIs from the task text. Failure modes (no API key,
timeout, parse error) degrade to empty kpis; the task still INSERTs
and the user can record progress manually.

**Env vars:**
- `HIVEMIND_RULES_TABLE`, `HIVEMIND_TASKS_TABLE`, `HIVEMIND_TASK_EVENTS_TABLE` — table names (default `hivemind_rules` / `hivemind_tasks` / `hivemind_task_events`).
- `HIVEMIND_KPI_MODEL` — model id for KPI generation (default `claude-sonnet-4-6`).
- `HIVEMIND_KPI_LLM=disable` — opt out of LLM KPI gen.
- `ANTHROPIC_API_KEY` — required for KPI gen; absence is a silent no-op (kpis = `[]`).
- `HIVEMIND_CAPTURE=false` — full read-only mode. Skips placeholder + ensure DDL; renderer still injects.

Full data model, identity contract, per-agent injection status, auto-extract pipeline, KPI LLM details, and known v1 limitations: **[docs/RULES_TASKS_KPIS.md](docs/RULES_TASKS_KPIS.md)**.

## Architecture

Per-agent integration mechanisms (marketplace plugin, hooks, skills, native extension) and monorepo structure: **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)**.
Expand Down
157 changes: 157 additions & 0 deletions claude-code/skills/hivemind-goals/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
name: hivemind-goals
description: Create, track and update team goals + KPIs via the Deeplake virtual filesystem at memory/goal/ and memory/kpi/. Use whenever the user mentions a goal, objective, KPI, target, milestone, or asks to track progress on something measurable.
allowed-tools: Read Write Edit Bash
---

# Hivemind Goals

Track goals and KPIs as Markdown files inside the Deeplake virtual filesystem. Each file is one row in a dedicated team-shared table — the path encodes the structural metadata, the file body holds the human-readable description.

## When to use this skill

Activate when the user expresses any of:
- "I want to track X / aim for X / track my progress on Y"
- "add a goal", "add a KPI", "what are my goals?"
- "mark this as done", "close that goal"
- "shipping X by Friday", "5 PRs this week", any measurable target

For "list my goals" → run `ls ~/.deeplake/memory/goal/<userName>/opened/` and `ls ~/.deeplake/memory/goal/<userName>/in_progress/`. If empty, ask the user if they want to create one.

## Path conventions (LEARN THESE)

```
~/.deeplake/memory/goal/<owner>/<status>/<goal_id>.md
~/.deeplake/memory/kpi/<goal_id>/<kpi_id>.md
```

- `<owner>` — user identifier (use the userName from `hivemind whoami` or the credentials)
- `<status>` — one of `opened`, `in_progress`, `closed`
- `<goal_id>` — UUIDv4 you generate at create time
- `<kpi_id>` — short slug like `k-prs` or `k-demos`

**Path encoding is the source of truth.** The owner, status, goal_id, and kpi_id come from the path — NOT from the file body. Do NOT write owner/status/goal_id/kpi_id inside the file content.

## File body format

Goal file body — plain markdown, free form:
```
ship the goals-graph feature

Notes: focus on KPI tracking via VFS, no separate CLI.
Due: 2026-05-30.
```

KPI file body — markdown with a few mandatory key:value lines so the commit-driven auto-progress worker can parse and bump:
```
PRs merged

- target: 5
- current: 2
- unit: count
```

The `target:`, `current:`, `unit:` lines must stay on a single line each. The first line is the human-readable name. Anything else is free notes.

## Operations

### 1. Create a new goal

When the user expresses a new goal:

1. Get the current owner with `hivemind whoami` (use the userName, e.g. `emanuele.fenocchi`).
2. Generate a UUIDv4: `uuidgen` or `node -e 'console.log(crypto.randomUUID())'`.
3. Write the goal file at `~/.deeplake/memory/goal/<owner>/opened/<uuid>.md` with the goal description as body.
4. Respond to the user that the goal is created.

**Do NOT auto-generate KPIs.** A goal is created with zero KPI files by default. Generate KPIs ONLY when the user explicitly asks you to ("aggiungi KPI per …", "add metrics for this goal", "track these metrics: …"). When the user asks, write each KPI as a separate file at `~/.deeplake/memory/kpi/<goal_id>/<kpi-slug>.md` with the body format documented above.

### 2. List goals

```bash
ls ~/.deeplake/memory/goal/<owner>/opened/
ls ~/.deeplake/memory/goal/<owner>/in_progress/
```

Then `cat` each `<uuid>.md` to read the body. Optionally `ls ~/.deeplake/memory/kpi/<uuid>/` and `cat` each KPI to surface progress.

### 3. Edit a goal description

```bash
# Use Read + Edit (or Write) on the existing file. The VFS handles
# version-bumping — every write produces a fresh row in the
# hivemind_goals table.
```

### 4. Move a goal to in_progress

```bash
mv ~/.deeplake/memory/goal/<owner>/opened/<uuid>.md ~/.deeplake/memory/goal/<owner>/in_progress/<uuid>.md
```

`mv` between status folders is an atomic version-bump. The file body carries over unchanged.

### 5. Close a goal

Two equivalent ways:

```bash
# Explicit mv to closed (recommended — clearest intent)
mv ~/.deeplake/memory/goal/<owner>/in_progress/<uuid>.md ~/.deeplake/memory/goal/<owner>/closed/<uuid>.md

# Or: rm (the VFS interprets rm on a goal path as a soft-close)
rm ~/.deeplake/memory/goal/<owner>/opened/<uuid>.md
```

**Important:** `rm` does NOT actually delete the goal. It is a soft-close — the VFS writes a new version with status=closed. The goal remains in the team-shared table for audit. There is no hard-delete in v1.

### 6. Add a KPI manually

```bash
Write the file at ~/.deeplake/memory/kpi/<uuid>/<kpi-slug>.md with:
<KPI name>

- target: <N>
- current: 0
- unit: <unit>
```

### 7. Record progress on a KPI

Read the KPI file, increment the `current:` line, write it back:

```
<KPI name>

- target: 5
- current: 3 ← incremented from 2
- unit: count
```

Use the Edit tool for the most surgical change (just the line with `current:`).

### 8. Reassign a goal (transfer ownership)

```bash
mv ~/.deeplake/memory/goal/<old-owner>/<status>/<uuid>.md ~/.deeplake/memory/goal/<new-owner>/<status>/<uuid>.md
```

Goal ownership lives in the path. KPI files do NOT have an owner segment — they are linked to the goal by `<uuid>`, so they need no change when a goal is reassigned.

## Constraints — DO NOT do these

- Do NOT put `owner`, `status`, `goal_id`, or `kpi_id` inside the file body. The path is the source of truth — duplicating in the body causes drift.
- Do NOT use status values other than `opened`, `in_progress`, `closed`.
- Do NOT rename the goal_id (the UUID in the filename) via `mv`. The VFS rejects goal_id renames.
- Do NOT block on the KPI generator subprocess — always spawn it detached (`nohup … &`).
- Do NOT use the old `hivemind tasks` CLI — that belonged to an earlier design and is being removed.

## Auto-progress from `git commit`

A PostToolUse hook listens for `git commit`. When it fires, it spawns the agent's native LLM in the background with the commit diff + the list of the current user's open goals. The LLM reads each goal + its KPIs, judges whether the commit advanced any KPI, and edits the relevant KPI file to bump `current:`. This is fire-and-forget; the user does not block on it.

To disable globally: `HIVEMIND_AUTO_KPI_FROM_COMMITS=false`.

## Team visibility

Every write goes to a team-shared table on Deeplake (`hivemind_goals` or `hivemind_kpis`). Other team members see your goals in their SessionStart context and via direct `ls` / `cat` on the same paths in their own VFS. No explicit sharing step needed.
157 changes: 157 additions & 0 deletions codex/skills/hivemind-goals/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
name: hivemind-goals
description: Create, track and update team goals + KPIs via the Deeplake virtual filesystem at memory/goal/ and memory/kpi/. Use whenever the user mentions a goal, objective, KPI, target, milestone, or asks to track progress on something measurable.
allowed-tools: Bash
---

# Hivemind Goals

Track goals and KPIs as Markdown files inside the Deeplake virtual filesystem. Each file is one row in a dedicated team-shared table — the path encodes the structural metadata, the file body holds the human-readable description.

## When to use this skill

Activate when the user expresses any of:
- "I want to track X / aim for X / track my progress on Y"
- "add a goal", "add a KPI", "what are my goals?"
- "mark this as done", "close that goal"
- "shipping X by Friday", "5 PRs this week", any measurable target

For "list my goals" → run `ls ~/.deeplake/memory/goal/<userName>/opened/` and `ls ~/.deeplake/memory/goal/<userName>/in_progress/`. If empty, ask the user if they want to create one.

## Path conventions (LEARN THESE)

```
~/.deeplake/memory/goal/<owner>/<status>/<goal_id>.md
~/.deeplake/memory/kpi/<goal_id>/<kpi_id>.md
```

- `<owner>` — user identifier (use the userName from `hivemind whoami` or the credentials)
- `<status>` — one of `opened`, `in_progress`, `closed`
- `<goal_id>` — UUIDv4 you generate at create time
- `<kpi_id>` — short slug like `k-prs` or `k-demos`

**Path encoding is the source of truth.** The owner, status, goal_id, and kpi_id come from the path — NOT from the file body. Do NOT write owner/status/goal_id/kpi_id inside the file content.

## File body format

Goal file body — plain markdown, free form:
```
ship the goals-graph feature

Notes: focus on KPI tracking via VFS, no separate CLI.
Due: 2026-05-30.
```

KPI file body — markdown with a few mandatory key:value lines so the commit-driven auto-progress worker can parse and bump:
```
PRs merged

- target: 5
- current: 2
- unit: count
```

The `target:`, `current:`, `unit:` lines must stay on a single line each. The first line is the human-readable name. Anything else is free notes.

## Operations

### 1. Create a new goal

When the user expresses a new goal:

1. Get the current owner with `hivemind whoami` (use the userName, e.g. `emanuele.fenocchi`).
2. Generate a UUIDv4: `uuidgen` or `node -e 'console.log(crypto.randomUUID())'`.
3. Write the goal file at `~/.deeplake/memory/goal/<owner>/opened/<uuid>.md` with the goal description as body.
4. Respond to the user that the goal is created.

**Do NOT auto-generate KPIs.** A goal is created with zero KPI files by default. Generate KPIs ONLY when the user explicitly asks you to ("aggiungi KPI per …", "add metrics for this goal", "track these metrics: …"). When the user asks, write each KPI as a separate file at `~/.deeplake/memory/kpi/<goal_id>/<kpi-slug>.md` with the body format documented above.

### 2. List goals

```bash
ls ~/.deeplake/memory/goal/<owner>/opened/
ls ~/.deeplake/memory/goal/<owner>/in_progress/
```

Then `cat` each `<uuid>.md` to read the body. Optionally `ls ~/.deeplake/memory/kpi/<uuid>/` and `cat` each KPI to surface progress.

### 3. Edit a goal description

```bash
# Use Read + Edit (or Write) on the existing file. The VFS handles
# version-bumping — every write produces a fresh row in the
# hivemind_goals table.
```

### 4. Move a goal to in_progress

```bash
mv ~/.deeplake/memory/goal/<owner>/opened/<uuid>.md ~/.deeplake/memory/goal/<owner>/in_progress/<uuid>.md
```

`mv` between status folders is an atomic version-bump. The file body carries over unchanged.

### 5. Close a goal

Two equivalent ways:

```bash
# Explicit mv to closed (recommended — clearest intent)
mv ~/.deeplake/memory/goal/<owner>/in_progress/<uuid>.md ~/.deeplake/memory/goal/<owner>/closed/<uuid>.md

# Or: rm (the VFS interprets rm on a goal path as a soft-close)
rm ~/.deeplake/memory/goal/<owner>/opened/<uuid>.md
```

**Important:** `rm` does NOT actually delete the goal. It is a soft-close — the VFS writes a new version with status=closed. The goal remains in the team-shared table for audit. There is no hard-delete in v1.

### 6. Add a KPI manually

```bash
Write the file at ~/.deeplake/memory/kpi/<uuid>/<kpi-slug>.md with:
<KPI name>

- target: <N>
- current: 0
- unit: <unit>
```

### 7. Record progress on a KPI

Read the KPI file, increment the `current:` line, write it back:

```
<KPI name>

- target: 5
- current: 3 ← incremented from 2
- unit: count
```

Use the Edit tool for the most surgical change (just the line with `current:`).

### 8. Reassign a goal (transfer ownership)

```bash
mv ~/.deeplake/memory/goal/<old-owner>/<status>/<uuid>.md ~/.deeplake/memory/goal/<new-owner>/<status>/<uuid>.md
```

Goal ownership lives in the path. KPI files do NOT have an owner segment — they are linked to the goal by `<uuid>`, so they need no change when a goal is reassigned.

## Constraints — DO NOT do these

- Do NOT put `owner`, `status`, `goal_id`, or `kpi_id` inside the file body. The path is the source of truth — duplicating in the body causes drift.
- Do NOT use status values other than `opened`, `in_progress`, `closed`.
- Do NOT rename the goal_id (the UUID in the filename) via `mv`. The VFS rejects goal_id renames.
- Do NOT block on the KPI generator subprocess — always spawn it detached (`nohup … &`).
- Do NOT use the old `hivemind tasks` CLI — that belonged to an earlier design and is being removed.

## Auto-progress from `git commit`

A PostToolUse hook listens for `git commit`. When it fires, it spawns the agent's native LLM in the background with the commit diff + the list of the current user's open goals. The LLM reads each goal + its KPIs, judges whether the commit advanced any KPI, and edits the relevant KPI file to bump `current:`. This is fire-and-forget; the user does not block on it.

To disable globally: `HIVEMIND_AUTO_KPI_FROM_COMMITS=false`.

## Team visibility

Every write goes to a team-shared table on Deeplake (`hivemind_goals` or `hivemind_kpis`). Other team members see your goals in their SessionStart context and via direct `ls` / `cat` on the same paths in their own VFS. No explicit sharing step needed.
Loading