Skip to content

feat(foraging): add CLI commands and SessionStart hook wiring#45

Merged
NagyVikt merged 1 commit intomainfrom
agent/claude/add-colony-foraging-cli-commands-and-ses-2026-04-24-12-21
Apr 24, 2026
Merged

feat(foraging): add CLI commands and SessionStart hook wiring#45
NagyVikt merged 1 commit intomainfrom
agent/claude/add-colony-foraging-cli-commands-and-ses-2026-04-24-12-21

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Automated by gx branch finish (PR flow).

Closes the foraging loop end-to-end.

CLI (`@imdeadpool/colony-cli`):

- `colony foraging scan [--cwd <path>]` — synchronous scan and
  re-index. Respects every `settings.foraging.*` limit
  (maxDepth / maxFileBytes / maxFilesPerSource / extraSecretEnvNames)
  and prints a one-line summary with the counts.
- `colony foraging list [--cwd <path>]` — prints the cached
  `examples` rows.
- `colony foraging clear [--example <name>] [--cwd <path>]` — drops
  rows plus their foraged-pattern observations.

The reserved `foraging` session owns every foraged-pattern
observation (fixed session id, not per-invocation) so session-wide
cleanup stays trivial.

Hooks (`@colony/hooks`):

- `sessionStart` detach-spawns `colony foraging scan --cwd <cwd>` via
  `@colony/process#spawnNodeScript` when `settings.foraging.enabled`
  and `scanOnSessionStart` are both true. Hook never waits — the
  preface surfaces state from previous scans only, preserving the
  150 ms p95 budget.
- New `buildForagingPreface(store, input)` renders a compact
  "## Examples indexed (foraging)" block with up to 5 example names,
  an overflow count, and a pointer at `examples_query` /
  `examples_integrate_plan`.

Foraging is now usable end-to-end without any manual setup: drop
example projects into `<repo_root>/examples/`, open a new session,
and the scanner indexes them in the background while the next
SessionStart surfaces them in the preface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@NagyVikt NagyVikt merged commit f8f1bcc into main Apr 24, 2026
@NagyVikt NagyVikt deleted the agent/claude/add-colony-foraging-cli-commands-and-ses-2026-04-24-12-21 branch April 24, 2026 10:30
NagyVikt added a commit that referenced this pull request Apr 24, 2026
…_plan (#46)

Fills the contract gap between the merged foraging PRs (#41, #43, #44,
#45) and CLAUDE.md's 'new MCP tool → update docs/mcp.md' rule. Each
entry lists inputs, return shape, and the non-obvious semantics
(vector re-rank skipped when filter is set; dependency_delta only
computed for npm; target_hint path resolution).

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant