saikei 0.1.0__py3-none-any.whl

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 (38) hide show
  1. saikei/__init__.py +5 -0
  2. saikei/claude_plugin/.claude-plugin/marketplace.json +12 -0
  3. saikei/claude_plugin/.claude-plugin/plugin.json +7 -0
  4. saikei/claude_plugin/hooks/hooks.json +10 -0
  5. saikei/claude_plugin/skills/capture/SKILL.md +15 -0
  6. saikei/claude_plugin/skills/next-task/SKILL.md +29 -0
  7. saikei/claude_plugin/skills/prioritise/SKILL.md +20 -0
  8. saikei/claude_plugin/skills/prune/SKILL.md +18 -0
  9. saikei/claude_plugin/skills/split/SKILL.md +20 -0
  10. saikei/claude_plugin/skills/using-bonsai/SKILL.md +64 -0
  11. saikei/cli.py +348 -0
  12. saikei/core.py +746 -0
  13. saikei/db.py +101 -0
  14. saikei/layout.py +316 -0
  15. saikei/migrations/__init__.py +0 -0
  16. saikei/migrations/env.py +32 -0
  17. saikei/migrations/script.py.mako +25 -0
  18. saikei/migrations/versions/0001_create_goal.py +44 -0
  19. saikei/migrations/versions/0002_rename_description_to_goal.py +31 -0
  20. saikei/migrations/versions/0003_rename_goal_to_branch.py +35 -0
  21. saikei/models.py +53 -0
  22. saikei/plugin.py +67 -0
  23. saikei/static/README.md +10 -0
  24. saikei/static/htmx.min.js +1 -0
  25. saikei/static/page.css +109 -0
  26. saikei/static/page.js +378 -0
  27. saikei/static/sse.js +290 -0
  28. saikei/templates/branch.html +56 -0
  29. saikei/templates/index.html +34 -0
  30. saikei/templates/save_status.html +1 -0
  31. saikei/templates/tree.svg +42 -0
  32. saikei/upgrade.py +43 -0
  33. saikei/web.py +276 -0
  34. saikei-0.1.0.dist-info/METADATA +44 -0
  35. saikei-0.1.0.dist-info/RECORD +38 -0
  36. saikei-0.1.0.dist-info/WHEEL +4 -0
  37. saikei-0.1.0.dist-info/entry_points.txt +4 -0
  38. saikei-0.1.0.dist-info/licenses/LICENSE +21 -0
saikei/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Project management tool for working with coding agents."""
2
+
3
+ import importlib.metadata
4
+
5
+ __version__ = importlib.metadata.version("saikei")
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "saikei",
3
+ "description": "The bonsai plugin bundled with the installed saikei package.",
4
+ "owner": { "name": "Momo Sophie Eissenhauer" },
5
+ "plugins": [
6
+ {
7
+ "name": "bonsai",
8
+ "description": "Skills for managing a saikei project tree together with an AI agent.",
9
+ "source": "./"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "bonsai",
3
+ "description": "Skills for managing a saikei project tree together with an AI agent.",
4
+ "version": "0.1.0",
5
+ "author": { "name": "Momo Sophie Eissenhauer" },
6
+ "license": "MIT"
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "matcher": "startup|clear|compact",
6
+ "hooks": [{ "type": "command", "command": "command -v bonsai >/dev/null 2>&1 && bonsai hook session-start || true" }]
7
+ }
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: capture
3
+ description: Use in a bonsai project when a new idea, bug, or follow-up comes up that is outside the current task, so it is recorded in the tree instead of forgotten or started.
4
+ ---
5
+
6
+ # Capture
7
+
8
+ 1. Do not switch to the new thing. Finish or pause the current task first.
9
+ 2. Run `bonsai list` (`bonsai list --all` if needed) and find the branch whose
10
+ goal the new item contributes to. That is the parent.
11
+ 3. Propose to the user: parent, title, one-sentence goal. Wait for their OK.
12
+ 4. Run `bonsai branch PARENT_ID "TITLE" --goal "GOAL"`. It ranks directly
13
+ above its parent; if it belongs elsewhere, suggest a position with
14
+ `bonsai:prioritise`.
15
+ 5. Return to the current task.
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: next-task
3
+ description: Use in a bonsai project when starting work, when the user says "next" or asks what to work on, or when a task is finished and the next one should begin.
4
+ ---
5
+
6
+ # Next task
7
+
8
+ 1. Run `bonsai list`.
9
+ 2. Pick the branch:
10
+ - A `doing` branch with no to-do or doing children: continue it. Tell the
11
+ user which one.
12
+ - Otherwise take the rank-0 to-do branch (doing parents stay doing while
13
+ their children are open; they are not the work item). If the user named
14
+ a branch, take that one. Tell the user which branch you picked and wait
15
+ for their OK.
16
+ 3. Run `bonsai show ID` and read the goal and its parent's goal.
17
+ 4. Too big to start in one go, or its goal is vague? Use `bonsai:split`
18
+ first and start on the first sub-branch instead.
19
+ 5. Run `bonsai status ID doing`. If it would move the branch or set other
20
+ branches back to todo, it changes nothing and exits with an error showing
21
+ the change and a token. That is expected: show the user the change and run
22
+ `bonsai status ID doing --confirm TOKEN` only after their OK.
23
+ 6. Do the work. If superpowers is available, hand the branch's title and
24
+ goal to `superpowers:brainstorming` as the request; the goal is the why.
25
+ 7. When the work is finished (merged or accepted by the user), run
26
+ `bonsai status ID done`.
27
+ 8. Run `bonsai show PARENT_ID`. If all its children are done now, ask the
28
+ user whether the parent is done too.
29
+ 9. Offer the next task; do not start it unasked.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: prioritise
3
+ description: Use in a bonsai project when the order of work should change - the user asks to reorder, something became urgent, or a branch turns out to depend on another.
4
+ ---
5
+
6
+ # Prioritise
7
+
8
+ 1. Run `bonsai list` to see the current order.
9
+ 2. Propose the change in plain words ("move #12 above #9 because ...") and
10
+ wait for the user's OK.
11
+ 3. Apply it:
12
+ - `bonsai move ID --above OTHER`: new row just above OTHER's row.
13
+ - `bonsai move ID --below OTHER`: new row just below OTHER's row.
14
+ - `bonsai move ID --tie OTHER`: into OTHER's row, meaning "order not
15
+ decided yet".
16
+ 4. Rules the CLI enforces: a branch stays above its parent and below the
17
+ done branches; sub-branches that would end up below it move up with it;
18
+ done branches and the trunk never move. If the CLI prints a note that the
19
+ branch was placed elsewhere, tell the user.
20
+ 5. Run `bonsai list` and show the user the new order.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: prune
3
+ description: Use in a bonsai project when a branch is no longer relevant - superseded, abandoned, or decided against - and should leave the tree.
4
+ ---
5
+
6
+ # Prune
7
+
8
+ Pruning removes a branch and all its sub-branches for good. The trunk cannot
9
+ be pruned.
10
+
11
+ 1. Run `bonsai show ID` and check its children: they go too.
12
+ 2. Propose the prune to the user with the reason. Wait for their OK.
13
+ 3. Run `bonsai prune ID`. It changes nothing yet and exits with an error
14
+ showing what would be pruned and a token. That is expected.
15
+ 4. Show the user that output. After their OK, run
16
+ `bonsai prune ID --confirm TOKEN`.
17
+ 5. If the parent now has only done children, ask the user whether the
18
+ parent is done too.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: split
3
+ description: Use in a bonsai project when a branch is too big or vague to start, when the user asks to break a goal down, or when planning reveals separate deliverables.
4
+ ---
5
+
6
+ # Split a branch
7
+
8
+ 1. Run `bonsai show ID` and read its goal and its parent's goal.
9
+ 2. Split only the branch that is next up. Leave future work coarse.
10
+ 3. Draft sub-branches. Each one:
11
+ - delivers one thing a user could notice or check;
12
+ - contributes to the parent's goal; together they achieve it;
13
+ - has a short title and a one or two sentence goal saying what is done
14
+ when it is done.
15
+ 4. Propose the list to the user, in the order you'd do them. Wait for their
16
+ OK and edits.
17
+ 5. Create each agreed sub-branch with
18
+ `bonsai branch ID "TITLE" --goal "GOAL"`, in the order you'd do them: the
19
+ first created ranks highest.
20
+ 6. Run `bonsai list` and show the user the result.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: using-bonsai
3
+ description: Use in any project with a `.bonsai/` folder - explains the bonsai project tree, the `bonsai` CLI, what you may change without asking, and which bonsai skill to use when.
4
+ ---
5
+
6
+ # Using bonsai
7
+
8
+ This project plans its work as a tree, managed with the `bonsai` CLI. The
9
+ user gardens the tree with you: splitting goals, ordering them, pruning dead
10
+ ones. The tree is the user's plan, so you read it freely but change its shape
11
+ only with their OK.
12
+
13
+ ## Concepts
14
+
15
+ - **Trunk:** the root, the project as a whole and its goal.
16
+ - **Branch:** a node with one deliverable goal that contributes to its
17
+ parent's goal. Leaves are the actual work items.
18
+ - **Status:** `todo`, `doing`, `done`. Only one subtree is doing (the focus),
19
+ plus the path from it up to the trunk. A branch can only be done when all
20
+ its sub-branches are done.
21
+ - **Priority** is a row: higher row = higher priority. `bonsai list` shows it
22
+ as RANK, 0 is highest.
23
+ - A child always ranks above its parent.
24
+ - Done branches never move; their order records the order work was done.
25
+ - Equal rank (a tie) means "order not decided yet".
26
+ - Refine just in time: only the next-up branch gets split into detail;
27
+ future work stays coarse.
28
+ - **Pruned** branches are removed from the tree for good, with their
29
+ sub-branches.
30
+
31
+ ## Commands
32
+
33
+ ```
34
+ bonsai list [--all] # to-do and doing by priority (--all adds done)
35
+ bonsai show ID # one branch as markdown: status, parent, children, goal
36
+ bonsai status ID todo|doing|done [--confirm TOKEN]
37
+ bonsai branch PARENT_ID TITLE [--goal TEXT] # prints the new id
38
+ bonsai move ID --above|--below|--tie OTHER
39
+ bonsai edit title ID TEXT
40
+ bonsai edit goal ID TEXT
41
+ bonsai prune ID [--confirm TOKEN]
42
+ bonsai ui # web UI for the user, http://127.0.0.1:8765
43
+ ```
44
+
45
+ ## What you may do without asking
46
+
47
+ - Free: `bonsai list`, `bonsai show`, `bonsai status ID doing`,
48
+ `bonsai status ID done`.
49
+ - Ask the user first: `bonsai status ID todo`, `bonsai branch`,
50
+ `bonsai move`, `bonsai prune`, `bonsai edit title`, `bonsai edit goal`.
51
+ Propose the exact change (titles, goals, positions), apply it after they
52
+ agree.
53
+ - `--confirm TOKEN`: some commands change nothing and exit with an error
54
+ showing the change they would make and a token. That is expected, not a
55
+ failure. Show the user that change; run with `--confirm TOKEN` only after
56
+ they agree. Never confirm on your own.
57
+
58
+ ## Which skill when
59
+
60
+ - Starting work, or "what's next?": `bonsai:next-task`
61
+ - A goal is too big to start, or needs a plan: `bonsai:split`
62
+ - Changing what comes first: `bonsai:prioritise`
63
+ - A new idea or problem comes up mid-task: `bonsai:capture`
64
+ - A branch is no longer relevant: `bonsai:prune`
saikei/cli.py ADDED
@@ -0,0 +1,348 @@
1
+ """Command line entrypoint, used by the agent."""
2
+
3
+ import logging
4
+ import pathlib
5
+
6
+ import click
7
+ import sqlalchemy
8
+
9
+ from saikei import core, db, models, plugin, upgrade, web
10
+
11
+ _logger = logging.getLogger(__name__)
12
+
13
+
14
+ @click.group()
15
+ def main() -> None:
16
+ """Manage a project tree together with an AI agent."""
17
+ logging.basicConfig(
18
+ level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s"
19
+ )
20
+ # Alembic narrates every schema check at INFO; only its warnings matter to the user.
21
+ logging.getLogger("alembic").setLevel(logging.WARNING)
22
+
23
+
24
+ @main.command()
25
+ def version() -> None:
26
+ """Print the saikei version."""
27
+ click.echo(core.version())
28
+
29
+
30
+ @main.command()
31
+ @click.option(
32
+ "--host", default="127.0.0.1", show_default=True, help="Interface to serve on."
33
+ )
34
+ @click.option(
35
+ "--port",
36
+ type=click.IntRange(1, 65535),
37
+ default=8765,
38
+ show_default=True,
39
+ help="Port to serve on.",
40
+ )
41
+ def ui(host: str, port: int) -> None:
42
+ """Start the web UI."""
43
+ _open_project().dispose()
44
+ database = db.find_database(pathlib.Path.cwd())
45
+ _logger.info("starting web ui url=http://%s:%d", host, port)
46
+ if not core.is_local_host(host):
47
+ _logger.warning(
48
+ "web ui has no authentication and is reachable from the network host=%s",
49
+ host,
50
+ )
51
+ web.run(database, host, port)
52
+
53
+
54
+ def _open_project() -> sqlalchemy.Engine:
55
+ try:
56
+ return core.open_project(pathlib.Path.cwd())
57
+ except db.ProjectNotFoundError as error:
58
+ raise click.ClickException(f"{error} — run `bonsai init` first") from error
59
+
60
+
61
+ @main.command()
62
+ @click.argument("title")
63
+ @click.option(
64
+ "--goal", default="", help="What the project as a whole sets out to achieve."
65
+ )
66
+ def init(title: str, goal: str) -> None:
67
+ """Start a project in the current folder, with TITLE as its trunk."""
68
+ try:
69
+ database = core.init_project(pathlib.Path.cwd(), title, goal)
70
+ except core.InvalidTitleError as error:
71
+ raise click.BadParameter(str(error), param_hint="TITLE") from error
72
+ except core.ProjectExistsError as error:
73
+ raise click.ClickException(str(error)) from error
74
+ click.echo(f"Created {database}")
75
+
76
+
77
+ @main.command()
78
+ @click.argument("parent_id", type=int)
79
+ @click.argument("title")
80
+ @click.option("--goal", default="", help="What this branch sets out to achieve.")
81
+ def branch(parent_id: int, title: str, goal: str) -> None:
82
+ """Create a sub-branch of PARENT_ID titled TITLE and print its id.
83
+
84
+ The new branch is to do and ranks directly above its parent.
85
+ """
86
+ engine = _open_project()
87
+ try:
88
+ branch_id = core.create_branch(engine, parent_id, title, goal)
89
+ except core.InvalidTitleError as error:
90
+ raise click.BadParameter(str(error), param_hint="TITLE") from error
91
+ except (
92
+ core.BranchNotFoundError,
93
+ core.BranchPrunedError,
94
+ core.BranchDoneError,
95
+ ) as error:
96
+ raise click.ClickException(str(error)) from error
97
+ finally:
98
+ engine.dispose()
99
+ click.echo(branch_id)
100
+
101
+
102
+ @main.command()
103
+ @click.argument("branch_id", metavar="ID", type=int)
104
+ @click.option("--above", type=int, metavar="OTHER", help="New row above OTHER's row.")
105
+ @click.option("--below", type=int, metavar="OTHER", help="New row below OTHER's row.")
106
+ @click.option("--tie", type=int, metavar="OTHER", help="Into OTHER's row.")
107
+ def move(branch_id: int, above: int | None, below: int | None, tie: int | None) -> None:
108
+ """Move branch ID to a new row above or below OTHER's row, or into OTHER's row (--tie).
109
+
110
+ A branch stays above its parent and below the done branches; sub-branches that would end
111
+ up below it move up with it. Prints a note when the branch was placed elsewhere.
112
+ """
113
+ given = [
114
+ (placement, target)
115
+ for placement, target in (
116
+ (core.Placement.ABOVE, above),
117
+ (core.Placement.BELOW, below),
118
+ (core.Placement.TIE, tie),
119
+ )
120
+ if target is not None
121
+ ]
122
+ if len(given) != 1:
123
+ raise click.UsageError("give exactly one of --above, --below, --tie")
124
+ [(placement, target_id)] = given
125
+ engine = _open_project()
126
+ try:
127
+ result = core.move_branch(engine, branch_id, placement, target_id)
128
+ except (
129
+ core.BranchNotFoundError,
130
+ core.BranchPrunedError,
131
+ core.BranchDoneError,
132
+ core.TrunkMoveError,
133
+ core.SameBranchMoveError,
134
+ ) as error:
135
+ raise click.ClickException(str(error)) from error
136
+ finally:
137
+ engine.dispose()
138
+ if result.message is not None:
139
+ click.echo(result.message)
140
+
141
+
142
+ @main.command()
143
+ @click.argument("branch_id", metavar="ID", type=int)
144
+ @click.argument("status", type=click.Choice([status.value for status in models.Status]))
145
+ @click.option(
146
+ "--confirm", metavar="TOKEN", help="Apply a change shown by an earlier run."
147
+ )
148
+ def status(branch_id: int, status: str, confirm: str | None) -> None:
149
+ """Set the status of branch ID.
150
+
151
+ Doing moves the branch to the top priority and makes it the only focus; when that moves
152
+ it or sets other branches back to todo, nothing changes and the change is printed with a
153
+ token: run again with --confirm TOKEN to apply exactly that change.
154
+ """
155
+ engine = _open_project()
156
+ try:
157
+ core.set_status(engine, branch_id, models.Status(status), confirmed=confirm)
158
+ except core.ConfirmationNeededError as error:
159
+ raise click.ClickException(
160
+ f"{error.change.summary}. Run again with --confirm {error.change.token}"
161
+ ) from error
162
+ except (
163
+ core.BranchNotFoundError,
164
+ core.BranchPrunedError,
165
+ core.BranchDoneError,
166
+ core.OpenChildrenError,
167
+ ) as error:
168
+ raise click.ClickException(str(error)) from error
169
+ finally:
170
+ engine.dispose()
171
+
172
+
173
+ @main.command()
174
+ @click.argument("branch_id", metavar="ID", type=int)
175
+ @click.option(
176
+ "--confirm", metavar="TOKEN", help="Apply a prune shown by an earlier run."
177
+ )
178
+ def prune(branch_id: int, confirm: str | None) -> None:
179
+ """Prune branch ID and its sub-branches from the tree, for good.
180
+
181
+ Nothing changes on the first run: it prints what would be pruned and a token. Run again
182
+ with --confirm TOKEN to prune exactly that.
183
+ """
184
+ engine = _open_project()
185
+ try:
186
+ core.prune_branch(engine, branch_id, confirmed=confirm)
187
+ except core.PruneConfirmationNeededError as error:
188
+ raise click.ClickException(
189
+ f"{error.prune.summary}. Run again with --confirm {error.prune.token}"
190
+ ) from error
191
+ except (
192
+ core.BranchNotFoundError,
193
+ core.BranchPrunedError,
194
+ core.TrunkPruneError,
195
+ ) as error:
196
+ raise click.ClickException(str(error)) from error
197
+ finally:
198
+ engine.dispose()
199
+
200
+
201
+ @main.command(name="list")
202
+ @click.option("--all", "include_done", is_flag=True, help="Also show done branches.")
203
+ def list_(include_done: bool) -> None:
204
+ """List branches by priority, highest first (to do and doing; --all adds done).
205
+
206
+ RANK is renumbered over the listed branches: 0 is the highest priority, equal numbers are
207
+ tied.
208
+ """
209
+ engine = _open_project()
210
+ try:
211
+ views = core.list_branches(engine, include_done)
212
+ finally:
213
+ engine.dispose()
214
+ click.echo(_format_table(views) if views else "No branches to show.")
215
+
216
+
217
+ @main.command()
218
+ @click.argument("branch_id", metavar="ID", type=int)
219
+ def show(branch_id: int) -> None:
220
+ """Show branch ID as markdown."""
221
+ engine = _open_project()
222
+ try:
223
+ details = core.get_branch(engine, branch_id)
224
+ except core.BranchNotFoundError as error:
225
+ raise click.ClickException(str(error)) from error
226
+ finally:
227
+ engine.dispose()
228
+ click.echo(_format_branch(details))
229
+
230
+
231
+ def _format_table(views: list[core.BranchView]) -> str:
232
+ header = ("RANK", "ID", "STATUS", "TITLE", "PARENT")
233
+ rows = [
234
+ (
235
+ str(v.rank),
236
+ str(v.id),
237
+ v.status.value,
238
+ v.title,
239
+ "-" if v.parent_id is None else str(v.parent_id),
240
+ )
241
+ for v in views
242
+ ]
243
+ widths = [
244
+ max(len(row[column]) for row in [header, *rows])
245
+ for column in range(len(header))
246
+ ]
247
+ right_aligned = {0, 1, 4}
248
+
249
+ def line(cells: tuple[str, ...]) -> str:
250
+ return " ".join(
251
+ cell.rjust(width) if column in right_aligned else cell.ljust(width)
252
+ for column, (cell, width) in enumerate(zip(cells, widths, strict=True))
253
+ )
254
+
255
+ return "\n".join(line(cells) for cells in [header, *rows])
256
+
257
+
258
+ def _format_branch(details: core.BranchDetails) -> str:
259
+ parent = (
260
+ "-"
261
+ if details.parent is None
262
+ else f"#{details.parent.id} {details.parent.title}"
263
+ )
264
+ children = ", ".join(f"#{child.id}" for child in details.children) or "-"
265
+ return (
266
+ f"# {details.title} (#{details.id})\n"
267
+ "\n"
268
+ f"Status: {details.status.value}{' (pruned)' if details.pruned else ''}\n"
269
+ f"Parent: {parent}\n"
270
+ f"Children: {children}\n"
271
+ "\n"
272
+ "## Goal\n"
273
+ "\n"
274
+ f"{details.goal or '(none)'}"
275
+ )
276
+
277
+
278
+ @main.group()
279
+ def edit() -> None:
280
+ """Change a branch's title or goal text."""
281
+
282
+
283
+ @edit.command(name="title")
284
+ @click.argument("branch_id", metavar="ID", type=int)
285
+ @click.argument("text")
286
+ def edit_title(branch_id: int, text: str) -> None:
287
+ """Set the title of branch ID to TEXT."""
288
+ engine = _open_project()
289
+ try:
290
+ core.edit_title(engine, branch_id, text)
291
+ except core.InvalidTitleError as error:
292
+ raise click.BadParameter(str(error), param_hint="TEXT") from error
293
+ except (core.BranchNotFoundError, core.BranchPrunedError) as error:
294
+ raise click.ClickException(str(error)) from error
295
+ finally:
296
+ engine.dispose()
297
+
298
+
299
+ @edit.command(name="goal")
300
+ @click.argument("branch_id", metavar="ID", type=int)
301
+ @click.argument("text")
302
+ def edit_goal(branch_id: int, text: str) -> None:
303
+ """Set the goal text of branch ID to TEXT (may be empty or span lines)."""
304
+ engine = _open_project()
305
+ try:
306
+ core.edit_goal(engine, branch_id, text)
307
+ except (core.BranchNotFoundError, core.BranchPrunedError) as error:
308
+ raise click.ClickException(str(error)) from error
309
+ finally:
310
+ engine.dispose()
311
+
312
+
313
+ @main.group()
314
+ def hook() -> None:
315
+ """Hooks run by the bonsai Claude Code plugin."""
316
+
317
+
318
+ @hook.command(name="session-start")
319
+ def hook_session_start() -> None:
320
+ """Print the context that loads the using-bonsai skill, inside a project only."""
321
+ output = plugin.session_start_output(pathlib.Path.cwd())
322
+ if output is not None:
323
+ click.echo(output)
324
+
325
+
326
+ @main.group(name="plugin")
327
+ def plugin_() -> None:
328
+ """The bonsai Claude Code plugin."""
329
+
330
+
331
+ @plugin_.command(name="install")
332
+ def plugin_install() -> None:
333
+ """Install or re-point the bonsai plugin in Claude Code, for the current user."""
334
+ try:
335
+ plugin.install()
336
+ except plugin.InstallError as error:
337
+ raise click.ClickException(str(error)) from error
338
+ click.echo("Installed bonsai plugin. Restart Claude Code to load it.")
339
+
340
+
341
+ @main.command(name="upgrade")
342
+ def upgrade_() -> None:
343
+ """Upgrade the system install of saikei and re-point the Claude plugin."""
344
+ try:
345
+ upgrade.upgrade()
346
+ except upgrade.UpgradeError as error:
347
+ raise click.ClickException(str(error)) from error
348
+ click.echo("Upgraded saikei. Restart Claude Code to load the new plugin.")