Remove shared context from ctx get output to avoid misleading project info
Shared entries (server, webhooks, workflow) were shown for every project, causing Claude to misattribute them. Now ctx get shows only project-specific data. Use --shared flag to include shared context when needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
af670871ed
commit
f9ec78ce1e
1 changed files with 14 additions and 13 deletions
27
ctx
27
ctx
|
|
@ -103,19 +103,18 @@ def cmd_init(args):
|
|||
|
||||
|
||||
def cmd_get(args):
|
||||
"""Get full context for a project (shared + project-specific + recent summaries)."""
|
||||
"""Get full context for a project (project-specific + recent summaries).
|
||||
Use --shared flag to also include shared context."""
|
||||
if len(args) < 1:
|
||||
print("Usage: ctx get <project>")
|
||||
print("Usage: ctx get <project> [--shared]")
|
||||
sys.exit(1)
|
||||
project = args[0]
|
||||
show_shared = "--shared" in args
|
||||
db = get_db()
|
||||
|
||||
# Session info
|
||||
session = db.execute("SELECT * FROM sessions WHERE name = ?", (project,)).fetchone()
|
||||
|
||||
# Shared context
|
||||
shared = db.execute("SELECT key, value FROM shared ORDER BY key").fetchall()
|
||||
|
||||
# Project context
|
||||
contexts = db.execute(
|
||||
"SELECT key, value FROM contexts WHERE project = ? ORDER BY key", (project,)
|
||||
|
|
@ -137,11 +136,13 @@ def cmd_get(args):
|
|||
print(f"PROJECT: {project} (not registered, use: ctx init)")
|
||||
print("=" * 60)
|
||||
|
||||
if shared:
|
||||
print("\n--- Shared Context ---")
|
||||
for row in shared:
|
||||
print(f"\n[{row['key']}]")
|
||||
print(row["value"])
|
||||
if show_shared:
|
||||
shared = db.execute("SELECT key, value FROM shared ORDER BY key").fetchall()
|
||||
if shared:
|
||||
print("\n--- Shared Context ---")
|
||||
for row in shared:
|
||||
print(f"\n[{row['key']}]")
|
||||
print(row["value"])
|
||||
|
||||
if contexts:
|
||||
print(f"\n--- {project} Context ---")
|
||||
|
|
@ -155,8 +156,8 @@ def cmd_get(args):
|
|||
print(f"\n[{row['created_at']}]")
|
||||
print(row["summary"])
|
||||
|
||||
if not shared and not contexts and not summaries:
|
||||
print("\nNo context stored yet. Use 'ctx set' or 'ctx shared set' to add.")
|
||||
if not contexts and not summaries:
|
||||
print("\nNo context stored yet. Use 'ctx set' to add project context.")
|
||||
|
||||
db.close()
|
||||
|
||||
|
|
@ -444,7 +445,7 @@ def print_help():
|
|||
print("ctx — Cross-session context manager for Claude Code\n")
|
||||
print("Commands:")
|
||||
print(" init <project> <desc> [dir] Register a new project")
|
||||
print(" get <project> Load full context (shared + project)")
|
||||
print(" get <project> [--shared] Load project context (optionally with shared)")
|
||||
print(" set <project> <key> <value> Set project context entry")
|
||||
print(" append <project> <key> <val> Append to existing entry")
|
||||
print(" shared get|set|delete Manage shared context")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue