@@ -43,13 +43,57 @@ def cli(ctx: click.Context) -> None:
4343def init () -> None :
4444 """Create .devscontext.yaml configuration interactively.
4545
46- Guides the user through setting up adapters and configuration.
47- Currently shows placeholder text with manual setup instructions.
46+ Creates a starter configuration file with common defaults.
4847 """
49- click .echo ("TODO: interactive setup" )
48+ from pathlib import Path
49+
50+ config_path = Path (".devscontext.yaml" )
51+
52+ if config_path .exists ():
53+ click .echo (f"Config file already exists: { config_path } " )
54+ if not click .confirm ("Overwrite?" , default = False ):
55+ click .echo ("Aborted." )
56+ return
57+
58+ config_content = """\
59+ # DevsContext Configuration
60+ # See https://github.com/anthropics/devscontext for documentation
61+
62+ adapters:
63+ jira:
64+ enabled: true
65+ base_url: "https://your-company.atlassian.net"
66+ email: "${JIRA_EMAIL}"
67+ api_token: "${JIRA_API_TOKEN}"
68+
69+ fireflies:
70+ enabled: false
71+ api_key: "${FIREFLIES_API_KEY}"
72+
73+ local_docs:
74+ enabled: true
75+ paths:
76+ - "./docs"
77+ - "./CLAUDE.md"
78+
79+ synthesis:
80+ provider: "anthropic"
81+ model: "claude-3-haiku-20240307"
82+
83+ cache:
84+ ttl_seconds: 300
85+ max_size: 100
86+ """
87+
88+ config_path .write_text (config_content )
89+ click .echo (f"Created { config_path } " )
5090 click .echo ()
51- click .echo ("For now, copy .devscontext.yaml.example to .devscontext.yaml" )
52- click .echo ("and configure your adapters manually." )
91+ click .echo ("Next steps:" )
92+ click .echo (" 1. Edit .devscontext.yaml with your Jira URL" )
93+ click .echo (" 2. Set environment variables:" )
94+ click .echo (" export JIRA_EMAIL='your-email@company.com'" )
95+ click .echo (" export JIRA_API_TOKEN='your-api-token'" )
96+ click .echo (" 3. Test: devscontext test --ticket YOUR-123" )
5397
5498
5599@cli .command ()
@@ -65,12 +109,48 @@ def test(ticket: str | None) -> None:
65109 Verifies that all enabled adapters can connect to their respective
66110 services. Optionally tests fetching context for a specific ticket.
67111 """
68- click .echo ("TODO: test connection" )
112+ import asyncio
113+
114+ from devscontext .config import load_devscontext_config
115+ from devscontext .core import DevsContextCore
116+
117+ try :
118+ config = load_devscontext_config ()
119+ except FileNotFoundError :
120+ click .echo ("No .devscontext.yaml found. Run 'devscontext init' first." )
121+ return
122+
123+ click .echo ("Testing adapter connections..." )
124+ click .echo ()
125+
126+ core = DevsContextCore (config )
127+
128+ async def run_health_checks () -> dict [str , bool ]:
129+ return await core .health_check ()
130+
131+ results = asyncio .run (run_health_checks ())
132+
133+ for adapter , healthy in results .items ():
134+ status = click .style ("✓" , fg = "green" ) if healthy else click .style ("✗" , fg = "red" )
135+ click .echo (f" { status } { adapter } " )
136+
69137 click .echo ()
138+
70139 if ticket :
71- click .echo (f"Would test fetching context for: { ticket } " )
140+ click .echo (f"Fetching context for { ticket } ..." )
141+
142+ async def fetch_context () -> str :
143+ result = await core .get_task_context (ticket )
144+ return result .synthesized
145+
146+ try :
147+ output = asyncio .run (fetch_context ())
148+ click .echo ()
149+ click .echo (output )
150+ except Exception as e :
151+ click .echo (f"Error: { e } " , err = True )
72152 else :
73- click .echo ("Use --ticket PROJ-123 to test fetching a specific ticket." )
153+ click .echo ("Use --ticket PROJ-123 to test fetching a ticket." )
74154
75155
76156@cli .command ()
0 commit comments