mirror of
https://github.com/vectorize-io/hindsight.git
synced 2026-09-14 19:31:49 +08:00
163fbb0ede
* feat(api)!: retire the bank profile and background endpoints
GET/PUT /v1/default/banks/{bank_id}/profile and
POST /v1/default/banks/{bank_id}/background have been deprecated for
several releases. They now answer 410 Gone with the replacement call in
the detail, joining the two endpoints (entity regenerate, synchronous
document export) that already do.
The routes stay in the OpenAPI spec with unchanged signatures, so no
generated SDK method disappears from under a caller — only the behaviour
changes.
Disposition traits and the reflect mission are bank configuration, and
already were: _get_bank_profile_authenticated overlaid config on top of
the legacy DB columns. The `name` these endpoints also returned is a
display-only label available on the bank list.
To make the config API a complete replacement, GET .../config is no
longer gated on HINDSIGHT_API_ENABLE_BANK_CONFIG_API — that flag now
gates only the writes (PATCH/DELETE). A bank must always be able to read
its own resolved settings.
Clients migrated in the same change:
- control plane: bank-profile-view and bank-config-view read disposition
and mission from the config API, the display name comes from the
filtered bank list, and the dead /api/profile proxy route is gone.
- hindsight-cli: `bank disposition`, `bank set-disposition` and the
hidden `bank background` move to the config API. `background` warns
that it now replaces the mission rather than LLM-merging into it —
nothing replaces that merge — and its `--no-update-disposition` flag
is accepted but ignored, as the server stopped inferring disposition
from the mission long ago.
- TS wrapper: getBankProfile carries a @deprecated pointer.
* test(control-plane): cover the composed bank profile, and drop its extra fetch
bank-context only needs the display name, so it reads the id-filtered bank
list directly instead of going through getBankProfile, which would also
fetch the bank config it has no use for.
* feat(cli)!: drop the deprecated `bank background` command
The server endpoint is gone, and the LLM merge it performed has no
replacement — `bank mission` sets the mission outright. Keeping the
command as an alias would have silently turned a merge into an
overwrite, so it is removed rather than repointed.
* fix(ci): update the CLI coverage manifest, doc example and TS client test
- .openapi-coverage.toml: the three retired operations move to [skip]
alongside export_documents_sync_removed, and the stale add_bank_background
/ update_bank_disposition field sections are dropped. The CLI helper is
renamed set_bank_disposition so it no longer satisfies the coverage grep
by name while calling update_bank_config underneath.
- cli-reference.sh: the two `bank background` snippets become one
`bank mission`, the command that replaces them.
- main_operations.test.ts: TestBankProfile asserts the 410 and reads the
same data back from the bank config. try/catch rather than .rejects,
since this file runs under both jest and Deno's @std/expect shim.
* style: rustfmt the CLI edits, and say why the 410 handlers keep unused params
204 lines
5.9 KiB
Bash
204 lines
5.9 KiB
Bash
#!/bin/bash
|
|
# CLI Reference examples for Hindsight
|
|
# Tests all documented CLI commands and flags
|
|
# Run: bash examples/api/cli-reference.sh
|
|
|
|
set -e
|
|
|
|
HINDSIGHT_URL="${HINDSIGHT_API_URL:-http://localhost:8888}"
|
|
BANK_ID="cli-test-bank"
|
|
DOC_ID="test-document-001"
|
|
|
|
# =============================================================================
|
|
# Setup
|
|
# =============================================================================
|
|
hindsight configure --api-url "$HINDSIGHT_URL"
|
|
|
|
# Create test data with a known document ID
|
|
hindsight memory retain "$BANK_ID" "Alice works at Google as a software engineer" --doc-id "$DOC_ID"
|
|
hindsight memory retain "$BANK_ID" "Bob is a data scientist who collaborates with Alice" --doc-id "$DOC_ID"
|
|
hindsight memory retain "$BANK_ID" "Alice and Bob work on machine learning projects"
|
|
# Create document for delete test early so it has time to index
|
|
hindsight memory retain "$BANK_ID" "Carol is a project manager who coordinates the engineering team" --doc-id "temp-doc-to-delete"
|
|
|
|
# Wait for memories to be indexed (LLM processing takes time)
|
|
sleep 5
|
|
|
|
# =============================================================================
|
|
# Configuration (cli.md - Configuration section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-configure]
|
|
hindsight configure --api-url http://localhost:8888
|
|
# [/docs:cli-configure]
|
|
|
|
|
|
# =============================================================================
|
|
# Core Memory Commands (cli.md - Core Commands section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-retain-basic]
|
|
hindsight memory retain $BANK_ID "Alice works at Google as a software engineer"
|
|
# [/docs:cli-retain-basic]
|
|
|
|
|
|
# [docs:cli-retain-context]
|
|
hindsight memory retain $BANK_ID "Bob loves hiking" --context "hobby discussion"
|
|
# [/docs:cli-retain-context]
|
|
|
|
|
|
# [docs:cli-retain-async]
|
|
hindsight memory retain $BANK_ID "Meeting notes" --async
|
|
# [/docs:cli-retain-async]
|
|
|
|
|
|
# [docs:cli-recall-basic]
|
|
hindsight memory recall $BANK_ID "What does Alice do?"
|
|
# [/docs:cli-recall-basic]
|
|
|
|
|
|
# [docs:cli-recall-options]
|
|
hindsight memory recall $BANK_ID "hiking recommendations" \
|
|
--budget high \
|
|
--max-tokens 8192
|
|
# [/docs:cli-recall-options]
|
|
|
|
|
|
# [docs:cli-recall-fact-type]
|
|
hindsight memory recall $BANK_ID "query" --fact-type world,observation
|
|
# [/docs:cli-recall-fact-type]
|
|
|
|
|
|
# [docs:cli-recall-trace]
|
|
hindsight memory recall $BANK_ID "query" --trace
|
|
# [/docs:cli-recall-trace]
|
|
|
|
|
|
# [docs:cli-reflect-basic]
|
|
hindsight memory reflect $BANK_ID "What do you know about Alice?"
|
|
# [/docs:cli-reflect-basic]
|
|
|
|
|
|
# [docs:cli-reflect-context]
|
|
hindsight memory reflect $BANK_ID "Should I learn Python?" --context "career advice"
|
|
# [/docs:cli-reflect-context]
|
|
|
|
|
|
# [docs:cli-reflect-budget]
|
|
hindsight memory reflect $BANK_ID "Summarize my week" --budget high
|
|
# [/docs:cli-reflect-budget]
|
|
|
|
|
|
# =============================================================================
|
|
# Bank Management (cli.md - Bank Management section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-bank-list]
|
|
hindsight bank list
|
|
# [/docs:cli-bank-list]
|
|
|
|
|
|
# [docs:cli-bank-disposition]
|
|
hindsight bank disposition $BANK_ID
|
|
# [/docs:cli-bank-disposition]
|
|
|
|
|
|
# [docs:cli-bank-stats]
|
|
hindsight bank stats $BANK_ID
|
|
# [/docs:cli-bank-stats]
|
|
|
|
|
|
# [docs:cli-bank-name]
|
|
hindsight bank name $BANK_ID "My Assistant"
|
|
# [/docs:cli-bank-name]
|
|
|
|
|
|
# [docs:cli-bank-mission]
|
|
hindsight bank mission $BANK_ID "I am a helpful AI assistant interested in technology"
|
|
# [/docs:cli-bank-mission]
|
|
|
|
|
|
# =============================================================================
|
|
# Document Management (cli.md - Document Management section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-document-list]
|
|
hindsight document list $BANK_ID
|
|
# [/docs:cli-document-list]
|
|
|
|
|
|
# [docs:cli-document-get]
|
|
hindsight document get $BANK_ID $DOC_ID
|
|
# [/docs:cli-document-get]
|
|
|
|
|
|
# [docs:cli-document-delete]
|
|
hindsight document delete $BANK_ID temp-doc-to-delete
|
|
# [/docs:cli-document-delete]
|
|
|
|
|
|
# =============================================================================
|
|
# Entity Management (cli.md - Entity Management section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-entity-list]
|
|
hindsight entity list $BANK_ID
|
|
# [/docs:cli-entity-list]
|
|
|
|
|
|
# Get an entity ID from the list output and use it
|
|
ENTITY_ID=$(hindsight entity list $BANK_ID -o json 2>/dev/null | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4 || echo "")
|
|
|
|
if [ -n "$ENTITY_ID" ]; then
|
|
# [docs:cli-entity-get]
|
|
hindsight entity get $BANK_ID $ENTITY_ID
|
|
# [/docs:cli-entity-get]
|
|
|
|
# [docs:cli-entity-regenerate]
|
|
hindsight entity regenerate $BANK_ID $ENTITY_ID
|
|
# [/docs:cli-entity-regenerate]
|
|
else
|
|
echo "No entities found yet, skipping entity get/regenerate"
|
|
fi
|
|
|
|
|
|
# =============================================================================
|
|
# Output Formats (cli.md - Output Formats section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-output-json]
|
|
hindsight memory recall $BANK_ID "query" -o json
|
|
# [/docs:cli-output-json]
|
|
|
|
|
|
# [docs:cli-output-yaml]
|
|
hindsight memory recall $BANK_ID "query" -o yaml
|
|
# [/docs:cli-output-yaml]
|
|
|
|
|
|
# =============================================================================
|
|
# Global Options (cli.md - Global Options section)
|
|
# =============================================================================
|
|
|
|
# [docs:cli-verbose]
|
|
hindsight memory recall $BANK_ID "Alice" -v
|
|
# [/docs:cli-verbose]
|
|
|
|
|
|
# [docs:cli-help]
|
|
hindsight --help
|
|
# [/docs:cli-help]
|
|
|
|
|
|
# [docs:cli-version]
|
|
hindsight --version
|
|
# [/docs:cli-version]
|
|
|
|
|
|
# =============================================================================
|
|
# Cleanup
|
|
# =============================================================================
|
|
curl -s -X DELETE "${HINDSIGHT_URL}/v1/default/banks/${BANK_ID}" > /dev/null
|
|
|
|
echo "cli-reference.sh: All examples passed"
|