bumblebee-cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/index.js +4214 -0
  2. package/dist/index.js.map +1 -0
  3. package/package.json +32 -18
  4. package/templates/skills/bb-agent/SKILL.md +180 -0
  5. package/templates/skills/bb-agent/references/bb-commands.md +124 -0
  6. package/templates/skills/bb-agent/references/investigate-workflow.md +150 -0
  7. package/templates/skills/bb-agent/references/parallel-workflow.md +105 -0
  8. package/templates/skills/bb-agent/references/prompts.md +144 -0
  9. package/templates/skills/bb-agent/references/status-transitions.md +93 -0
  10. package/templates/skills/bb-agent/references/workflow.md +178 -0
  11. package/README.md +0 -49
  12. package/bin/bb.mjs +0 -132
  13. package/python/bb_cli/__init__.py +0 -0
  14. package/python/bb_cli/__main__.py +0 -3
  15. package/python/bb_cli/api_client.py +0 -45
  16. package/python/bb_cli/commands/__init__.py +0 -0
  17. package/python/bb_cli/commands/agent.py +0 -2287
  18. package/python/bb_cli/commands/auth.py +0 -79
  19. package/python/bb_cli/commands/board.py +0 -47
  20. package/python/bb_cli/commands/comment.py +0 -34
  21. package/python/bb_cli/commands/daemon.py +0 -153
  22. package/python/bb_cli/commands/init.py +0 -83
  23. package/python/bb_cli/commands/item.py +0 -192
  24. package/python/bb_cli/commands/label.py +0 -43
  25. package/python/bb_cli/commands/project.py +0 -175
  26. package/python/bb_cli/commands/sprint.py +0 -84
  27. package/python/bb_cli/config.py +0 -136
  28. package/python/bb_cli/main.py +0 -44
  29. package/python/bb_cli/progress.py +0 -117
  30. package/python/bb_cli/streaming.py +0 -168
  31. package/python/pyproject.toml +0 -18
  32. package/python/requirements.txt +0 -4
  33. package/scripts/build.sh +0 -20
  34. package/scripts/postinstall.mjs +0 -146
@@ -0,0 +1,144 @@
1
+ # Prompt Templates Reference
2
+
3
+ Structure of prompts used in each phase of the agent workflow.
4
+
5
+ ## Common Header
6
+
7
+ All prompts start with:
8
+ ```
9
+ You are {action} {item_type} {key}: {title}
10
+
11
+ Type: {type} | Priority: {priority} [| Status: {status}]
12
+ ```
13
+
14
+ Followed by optional sections (included only when data exists):
15
+ - `## Description` — work item description
16
+ - `## Acceptance Criteria` — acceptance criteria
17
+ - `## Implementation Plan` / `## Existing Plan` — plan field
18
+ - `## Previous Comments / Progress` — formatted comment history
19
+ - `## Project Knowledge Base` — contents of CLAUDE.md, docs/knowledge.md, .claude/lessons-learned.md
20
+
21
+ ## Phase 1: Suggest (Analysis)
22
+
23
+ **Purpose**: Analyze the work item and produce a plan. No code changes.
24
+
25
+ **Key instruction**:
26
+ ```
27
+ Analyse this work item **and** the project source code. Return a Markdown plan:
28
+
29
+ 1. **Root Cause / Analysis** -- what needs to change and why
30
+ 2. **Files to Modify** -- list every file with a short description
31
+ 3. **Implementation Steps** -- numbered, concrete steps
32
+ 4. **Testing Strategy** -- how to verify the changes
33
+ 5. **Risks & Considerations** -- edge cases, breaking changes
34
+
35
+ IMPORTANT: Do NOT modify any files. Only analyse and produce the plan.
36
+ ```
37
+
38
+ **CLI command**: `bb agent suggest <id>`
39
+ **Claude flags**: `-p <prompt> --output-format text`
40
+ **Comment type**: `proposal`
41
+
42
+ ## Phase 2: Execute (Implementation)
43
+
44
+ **Purpose**: Implement the changes in a git worktree.
45
+
46
+ **Key instruction**:
47
+ ```
48
+ Implement the changes described in the plan / comments above.
49
+
50
+ 1. Follow the project's existing coding conventions and patterns
51
+ 2. Work through changes one file at a time
52
+ 3. Run existing tests after your changes and fix any failures
53
+ 4. Add new tests where appropriate
54
+ 5. Commit your work with a clear, descriptive commit message
55
+ 6. If you hit a blocker, document it clearly
56
+ ```
57
+
58
+ **CLI command**: `bb agent execute <id>`
59
+ **Claude flags**: `--output-format stream-json --verbose --permission-mode bypassPermissions --mcp-config -`
60
+ **Comment type**: `agent_output`
61
+
62
+ ## Phase 3: Test (Verification)
63
+
64
+ **Purpose**: Run tests and report results. No code changes.
65
+
66
+ **Key instruction**:
67
+ ```
68
+ Run ALL relevant tests and verify the implementation:
69
+
70
+ 1. Identify test commands from CLAUDE.md or project config
71
+ 2. Run all relevant test suites
72
+ 3. Check acceptance criteria from the work item
73
+ 4. Review the git diff for obvious issues
74
+
75
+ Return a structured test report:
76
+
77
+ ## Test Report
78
+ ### Results
79
+ - **Status**: PASS or FAIL
80
+ - **Tests run**: <count>
81
+ - **Passed**: <count>
82
+ - **Failed**: <count>
83
+
84
+ ### Failing Tests (if any)
85
+ ### Acceptance Criteria Check
86
+ ### Root Cause Analysis (if failures)
87
+
88
+ IMPORTANT: Do NOT fix any code. Only run tests and report results.
89
+ ```
90
+
91
+ **CLI command**: `bb agent test <id>`
92
+ **Claude flags**: `-p <prompt> --output-format text`
93
+ **Comment type**: `test_report`
94
+
95
+ ## Phase 4: Reimplement (Fix from Failure)
96
+
97
+ **Purpose**: Re-implement based on test failure feedback. Runs in worktree with full permissions.
98
+
99
+ **Key instruction**:
100
+ ```
101
+ **IMPORTANT: A previous implementation attempt had test failures.**
102
+ Read the comments below — they contain the original plan,
103
+ execution report, and test failure details.
104
+
105
+ 1. Read the test report and failure reasons from previous comments
106
+ 2. Identify what went wrong in the previous implementation
107
+ 3. Fix the issues — focus on root causes from the test report
108
+ 4. Ensure all tests pass after your changes
109
+ 5. Run the full test suite to verify no regressions
110
+ 6. Commit your fixes with a clear message referencing the re-implementation
111
+ ```
112
+
113
+ **CLI command**: `bb agent reimplement <id>`
114
+ **Claude flags**: `--output-format stream-json --verbose --permission-mode bypassPermissions --mcp-config -`
115
+ **Comment type**: `agent_output`
116
+
117
+ ## Comment Context Format
118
+
119
+ All phases receive previous comments formatted as:
120
+
121
+ ```markdown
122
+ ## Previous Comments / Progress
123
+
124
+ ### {author} [{type}] -- {created_at}
125
+ {body}
126
+
127
+ ### {author} [{type}] -- {created_at}
128
+ {body}
129
+ ```
130
+
131
+ This ensures the agent has full context of prior analysis, implementation attempts, and test results.
132
+
133
+ ## Full Loop Flow
134
+
135
+ ```
136
+ bb agent run <id> --auto-merge --target release/dev
137
+
138
+ Phase 1: suggest → post proposal comment → status: confirmed
139
+ Phase 2: execute → spawn Claude in worktree → post execution report
140
+ Phase 3: test → run tests → post test report
141
+ ├─ PASS → merge to target → status: resolved → cleanup worktree
142
+ └─ FAIL → status: failed → retry if --max-retries > 0
143
+ └─ reimplement → test again → ...
144
+ ```
@@ -0,0 +1,93 @@
1
+ # Status Transitions by Work Item Type
2
+
3
+ Valid statuses for each work item type, sourced from `api/src/schemas/work_item.py`.
4
+
5
+ ## Epic
6
+
7
+ ```
8
+ open → in_progress → done
9
+ ↘ cancelled
10
+ ```
11
+
12
+ Statuses: `open`, `in_progress`, `done`, `cancelled`
13
+
14
+ ## Story
15
+
16
+ ```
17
+ open → confirmed → approved → in_progress → in_review → resolved → closed
18
+
19
+ └─ failed → (reimplement) → in_progress
20
+ └─ needs_info → (clarify) → open
21
+ ```
22
+
23
+ Statuses: `open`, `confirmed`, `approved`, `in_progress`, `in_review`, `resolved`, `closed`, `failed`, `needs_info`
24
+
25
+ ## Task
26
+
27
+ ```
28
+ backlog → todo → in_progress → in_review → done
29
+ ```
30
+
31
+ Statuses: `backlog`, `todo`, `in_progress`, `in_review`, `done`
32
+
33
+ ## Bug
34
+
35
+ ```
36
+ open → confirmed → in_progress → in_review → resolved → closed
37
+ ↘ wont_fix
38
+ ```
39
+
40
+ Statuses: `open`, `confirmed`, `in_progress`, `in_review`, `resolved`, `closed`, `wont_fix`
41
+
42
+ ## Feature
43
+
44
+ ```
45
+ open → confirmed → approved → in_progress → in_review → resolved → closed
46
+ ```
47
+
48
+ Statuses: `open`, `confirmed`, `approved`, `in_progress`, `in_review`, `resolved`, `closed`
49
+
50
+ ## Chore
51
+
52
+ ```
53
+ open → in_progress → done
54
+ ```
55
+
56
+ Statuses: `open`, `in_progress`, `done`
57
+
58
+ ## Spike
59
+
60
+ ```
61
+ open → in_progress → done
62
+ ```
63
+
64
+ Statuses: `open`, `in_progress`, `done`
65
+
66
+ ## Agent Flow Status Mapping
67
+
68
+ | Phase | Action | Status Transition |
69
+ |-------|--------|-------------------|
70
+ | Suggest | Post analysis plan | `open` → `confirmed` |
71
+ | Confirm | User approves | `confirmed` → `approved` (manual) |
72
+ | Execute | Start implementation | `approved`/`confirmed`/`open` → `in_progress` |
73
+ | Test Pass | All tests green | `in_progress` → `in_review` |
74
+ | Test Fail | Tests failing | `in_progress` → `failed` |
75
+ | Reimplement | Fix from failure | `failed` → `in_progress` |
76
+ | Merge | Code merged | `in_review` → `resolved` |
77
+ | Close | User accepts | `resolved` → `closed` (manual) |
78
+
79
+ ## Default Statuses
80
+
81
+ | Type | Default |
82
+ |------|---------|
83
+ | epic | `open` |
84
+ | story | `open` |
85
+ | task | `backlog` |
86
+ | bug | `open` |
87
+ | feature | `open` |
88
+ | chore | `open` |
89
+ | spike | `open` |
90
+
91
+ ## Priorities
92
+
93
+ Valid priorities (all types): `critical`, `high`, `medium`, `low`, `none`
@@ -0,0 +1,178 @@
1
+ # Work Item Resolution Workflow
2
+
3
+ Step-by-step process for resolving a Bumblebee work item.
4
+
5
+ ## Step 1: Fetch Work Item Data
6
+
7
+ For each id_or_number provided, fetch the full item and its comments using MCP tools:
8
+
9
+ ```
10
+ bumblebee_work_items(action="get", item_id="<id>")
11
+ bumblebee_comments(action="list", work_item_id="<id>")
12
+ ```
13
+
14
+ Review all returned data:
15
+ - **Core**: title, type, description, status, priority, assignee
16
+ - **Criteria**: acceptance_criteria
17
+ - **Plan**: plan (pre-approved implementation plan, if set)
18
+ - **Context**: comments (proposals, execution reports, test reports)
19
+
20
+ For multiple items, fetch all in parallel to minimize round trips.
21
+
22
+ ## Step 2: Triage — Is This Actionable?
23
+
24
+ Before investing effort, check if the item has enough detail to act on. An item is **too generic** if:
25
+
26
+ - Description is vague with no concrete scope (e.g. "improve performance", "fix bugs")
27
+ - No acceptance criteria and no plan
28
+ - Cannot determine what files, features, or behaviors are involved
29
+
30
+ If the item is too generic:
31
+ ```
32
+ bumblebee_work_items(action="update", item_id="<id>", data='{"status":"needs_info"}')
33
+ bumblebee_comments(action="create", work_item_id="<id>", data='{"body":"Moved to needs_info — [explain what is missing]","type":"discussion"}')
34
+ ```
35
+ Then **stop**.
36
+
37
+ ## Step 3: Read Knowledge Base
38
+
39
+ Read project context to understand conventions before writing code:
40
+
41
+ - **CLAUDE.md** — project structure, commands, conventions
42
+ - **docs/knowledge.md** — tech stack details, status enums, patterns
43
+ - **.claude/lessons-learned.md** — previous learnings and gotchas
44
+
45
+ Use the knowledge to follow existing patterns rather than inventing new ones.
46
+
47
+ ## Step 4: Create Branch / Worktree
48
+
49
+ The CLI creates a git worktree for isolated work:
50
+
51
+ - **Worktree path**: `~/.bumblebee/worktrees/{project_slug}/item-{number}`
52
+ - **Branch**: `{type_prefix}/{key}_{slugified_title}`
53
+
54
+ Branch naming convention:
55
+ | Work Item Type | Prefix |
56
+ |---------------|--------|
57
+ | epic | `epic/` |
58
+ | story | `feat/` |
59
+ | task | `task/` |
60
+ | bug | `fix/` |
61
+ | feature | `feat/` |
62
+ | chore | `chore/` |
63
+ | spike | `spike/` |
64
+
65
+ Example: `feat/bb-42_user-authentication` in `~/.bumblebee/worktrees/my-project/item-42`
66
+
67
+ If using the skill interactively (not via CLI), create a branch manually:
68
+ ```bash
69
+ git checkout -b {type_prefix}/{key}_{slugified_title}
70
+ ```
71
+
72
+ ## Step 5: Update Status
73
+
74
+ Mark the item as in progress:
75
+ ```
76
+ bumblebee_work_items(action="update", item_id="<id>", data='{"status":"in_progress"}')
77
+ ```
78
+
79
+ ## Step 6: Plan or Execute
80
+
81
+ **If the item has a `plan` field:** The plan is pre-approved. Execute it directly — do not re-plan or skip steps.
82
+
83
+ **If no plan and task is complex** (touches 3+ files, multiple packages, or requires architectural decisions): Analyze first, then save the plan:
84
+ ```
85
+ bumblebee_comments(action="create", work_item_id="<id>", data='{"body":"<markdown plan>","type":"proposal"}')
86
+ ```
87
+
88
+ **If no plan and task is simple** (single file fix, straightforward change): Proceed directly to implementation.
89
+
90
+ ## Step 7: Implement
91
+
92
+ Write the code changes:
93
+
94
+ - **Stay on the feature branch** — never switch branches mid-work
95
+ - **Follow acceptance criteria** if provided
96
+ - **Match existing patterns** — use conventions from CLAUDE.md and surrounding code
97
+ - **Minimal changes** — only modify what's needed. Don't refactor surrounding code or "improve" things outside scope
98
+
99
+ ## Step 8: Run Tests
100
+
101
+ Run the appropriate test commands to catch regressions:
102
+
103
+ - Check CLAUDE.md for package-specific test commands
104
+ - Common commands: `pytest` (API), `vitest` / `npm test` (web), `npm run build` (web)
105
+ - Run from the correct package directory
106
+ - Fix any test failures before proceeding
107
+
108
+ ## Step 9: Self-Review
109
+
110
+ Review all changes via `git diff HEAD~1`:
111
+
112
+ - **Bugs**: incorrect logic, off-by-one errors, null risks
113
+ - **Dead code**: unused variables, unreachable branches
114
+ - **Edge cases**: empty arrays, missing null checks
115
+ - **Type issues**: incorrect casts, missing validation
116
+ - **Security**: injection risks, exposed secrets
117
+
118
+ Fix any issues found and commit separately.
119
+
120
+ ## Step 10: Code Simplify
121
+
122
+ Launch a code simplifier agent to polish the implementation:
123
+
124
+ ```
125
+ Task → subagent_type: "code-simplifier"
126
+ prompt: "Simplify the recently modified code. Focus on files changed
127
+ in the last 2 commits (run `git diff HEAD~2 --name-only`).
128
+ Look for redundancy, unnecessary complexity, and inconsistencies."
129
+ ```
130
+
131
+ Review and commit any simplifications.
132
+
133
+ ## Step 11: Commit
134
+
135
+ Stage and commit with a clear message:
136
+
137
+ - Use conventional commit format: `feat:`, `fix:`, `refactor:`, etc.
138
+ - Reference the work item key in the message (e.g. `feat: add auth flow [BB-42]`)
139
+ - Stage specific files — avoid `git add .`
140
+
141
+ ## Step 12: Test Gate
142
+
143
+ Run the full test suite one final time:
144
+
145
+ - If all tests pass → continue to Step 13
146
+ - If tests fail → post a test report comment, set status to `failed`, and stop
147
+
148
+ ```
149
+ bumblebee_comments(action="create", work_item_id="<id>", data='{"body":"<test report markdown>","type":"test_report"}')
150
+ bumblebee_work_items(action="update", item_id="<id>", data='{"status":"failed"}')
151
+ ```
152
+
153
+ ## Step 13: Post Comment
154
+
155
+ Post a summary comment on the work item:
156
+
157
+ ```
158
+ bumblebee_comments(action="create", work_item_id="<id>", data='{"body":"<summary of changes>","type":"agent_output"}')
159
+ ```
160
+
161
+ The comment should cover:
162
+ - What was implemented or fixed
163
+ - Key design decisions
164
+ - Any caveats or follow-up items
165
+
166
+ ## Step 14: Resolve
167
+
168
+ After tests pass, review is clean, and changes are committed:
169
+
170
+ ```
171
+ bumblebee_work_items(action="update", item_id="<id>", data='{"status":"in_review"}')
172
+ ```
173
+
174
+ Suggest the merge command:
175
+ ```
176
+ Merge with: git checkout release/dev && git merge {branch}
177
+ Or: bb agent merge --target release/dev
178
+ ```
package/README.md DELETED
@@ -1,49 +0,0 @@
1
- # bumblebee-cli
2
-
3
- npm wrapper for the Bumblebee CLI — dev task management + Claude Code automation.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install -g bumblebee-cli
9
- ```
10
-
11
- **Requires Python 3.12+**. The postinstall script will automatically set up a Python virtual environment if `bb` is not already installed.
12
-
13
- ## Usage
14
-
15
- ```bash
16
- bb --help
17
- bb login
18
- bb item list
19
- bb agent suggest BB-42
20
- bb agent run BB-42 # Full cycle: verify → execute → test → merge
21
- bb agent daemon start # Long-running daemon for web-initiated sessions
22
- ```
23
-
24
- ## How it works
25
-
26
- This is a thin Node.js wrapper around the Python CLI. It resolves `bb` in this order:
27
-
28
- 1. System `bb` on PATH (if you installed via `pip install bumblebee-cli`)
29
- 2. Local `.venv` created by the npm postinstall script
30
- 3. `python -m bb_cli` as a fallback
31
-
32
- ## Manual Python install
33
-
34
- If the automatic setup doesn't work, install the Python CLI directly:
35
-
36
- ```bash
37
- pip install bumblebee-cli
38
- ```
39
-
40
- ## Project-local config
41
-
42
- Initialize a project-local config:
43
-
44
- ```bash
45
- cd your-project
46
- bb init --project my-app
47
- ```
48
-
49
- This creates `.bumblebee/config.toml` which overrides `~/.bumblebee/config.toml` settings (except credentials).
package/bin/bb.mjs DELETED
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { execFileSync, execSync } from "node:child_process";
4
- import { existsSync, readFileSync } from "node:fs";
5
- import { dirname, join, resolve } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
-
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
9
- const pkgRoot = join(__dirname, "..");
10
- const args = process.argv.slice(2);
11
-
12
- /**
13
- * Thin Node.js wrapper for the Bumblebee Python CLI.
14
- *
15
- * Resolution order:
16
- * 1. `bb` already on PATH (user installed via pip — not our own npm wrapper)
17
- * 2. Local .venv created by postinstall
18
- * 3. `python -m bb_cli` (fallback)
19
- */
20
-
21
- function getNpmGlobalPrefix() {
22
- try {
23
- return execSync("npm prefix -g", { encoding: "utf8", stdio: "pipe" }).trim();
24
- } catch {
25
- return null;
26
- }
27
- }
28
-
29
- function isOurOwnWrapper(bbPath) {
30
- // Check if the found bb is inside our npm package or the npm global bin
31
- const normalized = resolve(bbPath).toLowerCase();
32
- if (normalized.includes("node_modules") && normalized.includes("bumblebee-cli")) {
33
- return true;
34
- }
35
- // On Windows/Linux, npm global installs create shims in the npm prefix dir
36
- const npmPrefix = getNpmGlobalPrefix();
37
- if (npmPrefix && normalized.startsWith(resolve(npmPrefix).toLowerCase())) {
38
- return true;
39
- }
40
- return false;
41
- }
42
-
43
- // 1. Check if `bb` is already available on PATH (pip install)
44
- function trySystemBb() {
45
- try {
46
- const which = process.platform === "win32" ? "where" : "which";
47
- const result = execSync(`${which} bb`, { stdio: "pipe", encoding: "utf8" });
48
- // On Windows, `where` may return multiple lines; check each
49
- const paths = result.trim().split(/\r?\n/);
50
- for (const bbPath of paths) {
51
- const p = bbPath.trim();
52
- if (p && !isOurOwnWrapper(p)) {
53
- return p;
54
- }
55
- }
56
- } catch {
57
- // not found
58
- }
59
- return null;
60
- }
61
-
62
- // 2. Check local .venv
63
- function tryLocalVenv() {
64
- const isWin = process.platform === "win32";
65
- const venvBb = isWin
66
- ? join(pkgRoot, ".venv", "Scripts", "bb.exe")
67
- : join(pkgRoot, ".venv", "bin", "bb");
68
- if (existsSync(venvBb)) {
69
- return venvBb;
70
- }
71
- return null;
72
- }
73
-
74
- // 3. Fallback to python -m bb_cli
75
- function tryPythonModule() {
76
- const pythonCmds =
77
- process.platform === "win32" ? ["python", "python3"] : ["python3", "python"];
78
- for (const py of pythonCmds) {
79
- try {
80
- execSync(`${py} -c "import bb_cli"`, { stdio: "pipe" });
81
- return { python: py, module: true };
82
- } catch {
83
- // try next
84
- }
85
- }
86
- return null;
87
- }
88
-
89
- // --- Main ---
90
-
91
- const systemBb = trySystemBb();
92
- if (systemBb) {
93
- try {
94
- execFileSync(systemBb, args, { stdio: "inherit" });
95
- process.exit(0);
96
- } catch (e) {
97
- process.exit(e.status ?? 1);
98
- }
99
- }
100
-
101
- const venvBb = tryLocalVenv();
102
- if (venvBb) {
103
- try {
104
- execFileSync(venvBb, args, { stdio: "inherit" });
105
- process.exit(0);
106
- } catch (e) {
107
- process.exit(e.status ?? 1);
108
- }
109
- }
110
-
111
- const pyFallback = tryPythonModule();
112
- if (pyFallback) {
113
- try {
114
- execFileSync(pyFallback.python, ["-m", "bb_cli", ...args], {
115
- stdio: "inherit",
116
- });
117
- process.exit(0);
118
- } catch (e) {
119
- process.exit(e.status ?? 1);
120
- }
121
- }
122
-
123
- console.error(
124
- "Error: Could not find the Bumblebee Python CLI.\n" +
125
- "\n" +
126
- "The npm package needs the Python CLI installed. Fix with ONE of:\n" +
127
- " 1. pip install bumblebee-cli (install globally)\n" +
128
- " 2. npm rebuild bumblebee-cli (retry postinstall setup)\n" +
129
- "\n" +
130
- "Requires Python 3.12+ — https://python.org"
131
- );
132
- process.exit(1);
File without changes
@@ -1,3 +0,0 @@
1
- from bb_cli.main import app
2
-
3
- app()
@@ -1,45 +0,0 @@
1
- import httpx
2
-
3
- from .config import get_api_url, get_token
4
-
5
-
6
- def get_client() -> httpx.Client:
7
- headers = {}
8
- token = get_token()
9
- if token:
10
- headers["Authorization"] = f"Bearer {token}"
11
- return httpx.Client(base_url=get_api_url(), headers=headers, timeout=30)
12
-
13
-
14
- def api_get(path: str, params: dict | None = None) -> dict | list:
15
- with get_client() as client:
16
- resp = client.get(path, params=params)
17
- resp.raise_for_status()
18
- return resp.json()
19
-
20
-
21
- def api_post(path: str, json: dict | None = None, params: dict | None = None) -> dict:
22
- with get_client() as client:
23
- resp = client.post(path, json=json, params=params)
24
- resp.raise_for_status()
25
- return resp.json()
26
-
27
-
28
- def api_put(path: str, json: dict) -> dict:
29
- with get_client() as client:
30
- resp = client.put(path, json=json)
31
- resp.raise_for_status()
32
- return resp.json()
33
-
34
-
35
- def api_patch(path: str, json: dict) -> dict:
36
- with get_client() as client:
37
- resp = client.patch(path, json=json)
38
- resp.raise_for_status()
39
- return resp.json()
40
-
41
-
42
- def api_delete(path: str):
43
- with get_client() as client:
44
- resp = client.delete(path)
45
- resp.raise_for_status()
File without changes