kd-cli 2.3.0__tar.gz → 2.4.0__tar.gz
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.
- {kd_cli-2.3.0/kd_cli.egg-info → kd_cli-2.4.0}/PKG-INFO +1 -1
- kd_cli-2.4.0/kd/cli/core/confirm.py +43 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/core/option_registry.py +1 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/main.py +2 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/primer/__init__.py +49 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/project/__init__.py +25 -1
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/tag/__init__.py +25 -1
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/user/__init__.py +34 -4
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/primer.py +47 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/resources/CHANGELOG.md +6 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/resources/operating-guide.md +11 -1
- kd_cli-2.4.0/kd/resources/primers/__init__.py +0 -0
- kd_cli-2.4.0/kd/resources/primers/hitl.yaml +41 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0/kd_cli.egg-info}/PKG-INFO +1 -1
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd_cli.egg-info/SOURCES.txt +3 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/pyproject.toml +2 -2
- {kd_cli-2.3.0 → kd_cli-2.4.0}/LICENSE +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/MANIFEST.in +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/README.md +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/articles.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/http.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/hub.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/saved_queries.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/tags.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/api/youtrack.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/article_marker.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/auth.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/core/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/core/command_base.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/core/command_parser.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/core/namespaces.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/input.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/alias/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/article/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/init.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/issue/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/query/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/release_notes.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/search/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/system/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/namespaces/time/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/output.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/cli/tree.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/client.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/config.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/config_read.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/config_schema.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/connection.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/debug.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/exceptions.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/history.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/article.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/assist.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/attachment.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/comment.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/common.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/issue.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/project.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/saved_query.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/search.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/tag.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/tag_entities.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/user.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/models/work_item.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/operating_guide.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/query_parser.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/release_notes.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/resources/__init__.py +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/resources/command-synonyms.yaml +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/resources/config-template.yaml +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd/resources/error-messages.yaml +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd_cli.egg-info/dependency_links.txt +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd_cli.egg-info/entry_points.txt +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd_cli.egg-info/requires.txt +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/kd_cli.egg-info/top_level.txt +0 -0
- {kd_cli-2.3.0 → kd_cli-2.4.0}/setup.cfg +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Confirmation guard for irreversible destructive commands.
|
|
2
|
+
|
|
3
|
+
Some destructive commands bypass YouTrack's Deleted Items safety net —
|
|
4
|
+
project, tag, and user deletes in particular. This helper enforces an
|
|
5
|
+
opt-in ``--confirm`` flag: without it the command aborts with an
|
|
6
|
+
actionable multi-line error; with it the delete proceeds.
|
|
7
|
+
|
|
8
|
+
The error follows the ``_missing_tag_resolution`` pattern from
|
|
9
|
+
``kd.client``: a human-readable explanation plus a ``suggestion`` line
|
|
10
|
+
that spells out the literal retry command so an LLM reading the
|
|
11
|
+
stderr can proceed without extra reasoning.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import shlex
|
|
17
|
+
|
|
18
|
+
from kd.exceptions import ValidationError
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def require_confirm(
|
|
22
|
+
*,
|
|
23
|
+
confirmed: bool,
|
|
24
|
+
command: str,
|
|
25
|
+
entity_id: str,
|
|
26
|
+
caveat: str,
|
|
27
|
+
) -> None:
|
|
28
|
+
"""Abort unless ``--confirm`` was passed.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
confirmed: Whether the caller passed ``--confirm``.
|
|
32
|
+
command: Full command path, e.g. ``/project delete``.
|
|
33
|
+
entity_id: The target identifier as given on the command line.
|
|
34
|
+
caveat: One or two sentences explaining why this particular
|
|
35
|
+
delete is unsafe — the per-entity failure mode (issues
|
|
36
|
+
vanishing, tag membership gone, identity refs detaching).
|
|
37
|
+
"""
|
|
38
|
+
if confirmed:
|
|
39
|
+
return
|
|
40
|
+
raise ValidationError(
|
|
41
|
+
f"kd {command} {entity_id} is irreversible. {caveat}",
|
|
42
|
+
suggestion=(f"Retry with: kd {command} {shlex.quote(entity_id)} --confirm"),
|
|
43
|
+
)
|
|
@@ -547,6 +547,8 @@ def _print_namespace_reference(ns: Namespace, depth: int = 0) -> None:
|
|
|
547
547
|
|
|
548
548
|
# Options
|
|
549
549
|
for opt in cmd.get_options():
|
|
550
|
+
if opt.hidden_from_reference:
|
|
551
|
+
continue
|
|
550
552
|
flag = f"--{opt.name}"
|
|
551
553
|
if opt.short_name:
|
|
552
554
|
flag += f"/-{opt.short_name}"
|
|
@@ -26,6 +26,7 @@ from kd.primer import (
|
|
|
26
26
|
clear_articles,
|
|
27
27
|
clear_notes,
|
|
28
28
|
clear_tags,
|
|
29
|
+
init_primer,
|
|
29
30
|
load_primer,
|
|
30
31
|
remove_article,
|
|
31
32
|
remove_note,
|
|
@@ -107,6 +108,53 @@ class PrimerShowCommand(Command):
|
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
|
|
111
|
+
# ---------------------------------------------------------------------------
|
|
112
|
+
# /primer init
|
|
113
|
+
# ---------------------------------------------------------------------------
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class PrimerInitCommand(Command):
|
|
117
|
+
"""Scaffold ``.kd/primer.yaml`` from a packaged template."""
|
|
118
|
+
|
|
119
|
+
def __init__(self) -> None:
|
|
120
|
+
super().__init__(
|
|
121
|
+
"init",
|
|
122
|
+
"Scaffold .kd/primer.yaml from a template",
|
|
123
|
+
usage="kd /primer init [TEMPLATE]",
|
|
124
|
+
long_description=(
|
|
125
|
+
"Creates .kd/primer.yaml from a packaged template. Default "
|
|
126
|
+
"template is `hitl` — a human-in-the-loop session workflow "
|
|
127
|
+
"scaffold with placeholder prose in the scope-guard, session-"
|
|
128
|
+
"workflow, and canonical-reference slots. The template is "
|
|
129
|
+
"copied through unchanged so its banner and example-shape "
|
|
130
|
+
"comments survive. Refuses if a primer already exists; "
|
|
131
|
+
"there is no --force (deletion is explicit operator work)."
|
|
132
|
+
),
|
|
133
|
+
examples=[
|
|
134
|
+
"kd /primer init",
|
|
135
|
+
"kd /primer init hitl",
|
|
136
|
+
],
|
|
137
|
+
see_also=["/primer show", "/primer/note list"],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def _register_options(self) -> None:
|
|
141
|
+
self.register_option(project_option(help_text="Assert which project's primer this edits"))
|
|
142
|
+
|
|
143
|
+
def execute(
|
|
144
|
+
self, args: list[str], options: ResolvedOptions, client: Any = None
|
|
145
|
+
) -> CommandResult:
|
|
146
|
+
_assert_workspace_project(self, options)
|
|
147
|
+
template = args[0] if args else "hitl"
|
|
148
|
+
created = init_primer(template)
|
|
149
|
+
return {
|
|
150
|
+
"ok": True,
|
|
151
|
+
"action": "init",
|
|
152
|
+
"template": template,
|
|
153
|
+
"created": str(created),
|
|
154
|
+
"next": "kd /primer show -o yaml",
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
110
158
|
# ---------------------------------------------------------------------------
|
|
111
159
|
# /primer/note
|
|
112
160
|
# ---------------------------------------------------------------------------
|
|
@@ -534,6 +582,7 @@ def create_primer_namespace() -> Namespace:
|
|
|
534
582
|
path="primer",
|
|
535
583
|
)
|
|
536
584
|
ns.register_command("show", PrimerShowCommand())
|
|
585
|
+
ns.register_command("init", PrimerInitCommand())
|
|
537
586
|
|
|
538
587
|
# /primer/note
|
|
539
588
|
note_ns = Namespace("note", "Primer notes and conventions", path="primer/note")
|
|
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
from typing import Any
|
|
10
10
|
|
|
11
11
|
from kd.cli.core.command_base import Command, CommandResult
|
|
12
|
+
from kd.cli.core.confirm import require_confirm
|
|
12
13
|
from kd.cli.core.namespaces import Namespace
|
|
13
14
|
from kd.cli.core.option_registry import (
|
|
14
15
|
OptionDeclaration,
|
|
@@ -153,9 +154,22 @@ class ProjectDeleteCommand(Command):
|
|
|
153
154
|
"Delete a project",
|
|
154
155
|
requires_client=True,
|
|
155
156
|
usage="kd /project delete KEY",
|
|
156
|
-
examples=["kd /project delete TST"],
|
|
157
|
+
examples=["kd /project delete TST --confirm"],
|
|
157
158
|
see_also=["/project list"],
|
|
158
159
|
)
|
|
160
|
+
self.register_option(
|
|
161
|
+
OptionDeclaration(
|
|
162
|
+
name="confirm",
|
|
163
|
+
layer=OptionLayer.COMMAND,
|
|
164
|
+
type=bool,
|
|
165
|
+
default=False,
|
|
166
|
+
help_text=(
|
|
167
|
+
"Required — project delete is not recoverable from "
|
|
168
|
+
"Deleted Items (issues and articles are permanently removed)"
|
|
169
|
+
),
|
|
170
|
+
hidden_from_reference=True,
|
|
171
|
+
)
|
|
172
|
+
)
|
|
159
173
|
|
|
160
174
|
def execute(
|
|
161
175
|
self, args: list[str], options: ResolvedOptions, client: Any = None
|
|
@@ -163,6 +177,16 @@ class ProjectDeleteCommand(Command):
|
|
|
163
177
|
if not args:
|
|
164
178
|
raise ValidationError("Usage: kd /project delete KEY")
|
|
165
179
|
key = args[0]
|
|
180
|
+
require_confirm(
|
|
181
|
+
confirmed=bool(options.command.get("confirm")),
|
|
182
|
+
command="/project delete",
|
|
183
|
+
entity_id=key,
|
|
184
|
+
caveat=(
|
|
185
|
+
"All issues and articles in the project are permanently "
|
|
186
|
+
"deleted (they are not moved to Deleted Items) — recovery "
|
|
187
|
+
"requires a database backup restore."
|
|
188
|
+
),
|
|
189
|
+
)
|
|
166
190
|
client.projects.delete(key)
|
|
167
191
|
return {"ok": True, "action": "delete", "project": key}
|
|
168
192
|
|
|
@@ -10,6 +10,7 @@ import sys
|
|
|
10
10
|
from typing import Any, Literal
|
|
11
11
|
|
|
12
12
|
from kd.cli.core.command_base import Command, CommandResult
|
|
13
|
+
from kd.cli.core.confirm import require_confirm
|
|
13
14
|
from kd.cli.core.namespaces import Namespace
|
|
14
15
|
from kd.cli.core.option_registry import (
|
|
15
16
|
OptionDeclaration,
|
|
@@ -203,9 +204,22 @@ class TagDeleteCommand(Command):
|
|
|
203
204
|
"Delete a tag",
|
|
204
205
|
requires_client=True,
|
|
205
206
|
usage="kd /tag delete TAG_NAME",
|
|
206
|
-
examples=["kd /tag delete sprint-47"],
|
|
207
|
+
examples=["kd /tag delete sprint-47 --confirm"],
|
|
207
208
|
see_also=["/tag list", "/tag create"],
|
|
208
209
|
)
|
|
210
|
+
self.register_option(
|
|
211
|
+
OptionDeclaration(
|
|
212
|
+
name="confirm",
|
|
213
|
+
layer=OptionLayer.COMMAND,
|
|
214
|
+
type=bool,
|
|
215
|
+
default=False,
|
|
216
|
+
help_text=(
|
|
217
|
+
"Required — tag delete is not recoverable from Deleted "
|
|
218
|
+
"Items (tag membership is lost across all entities)"
|
|
219
|
+
),
|
|
220
|
+
hidden_from_reference=True,
|
|
221
|
+
)
|
|
222
|
+
)
|
|
209
223
|
|
|
210
224
|
def execute(
|
|
211
225
|
self, args: list[str], options: ResolvedOptions, client: Any = None
|
|
@@ -213,6 +227,16 @@ class TagDeleteCommand(Command):
|
|
|
213
227
|
if not args:
|
|
214
228
|
raise ValidationError("Usage: kd /tag delete TAG_NAME")
|
|
215
229
|
name = args[0]
|
|
230
|
+
require_confirm(
|
|
231
|
+
confirmed=bool(options.command.get("confirm")),
|
|
232
|
+
command="/tag delete",
|
|
233
|
+
entity_id=name,
|
|
234
|
+
caveat=(
|
|
235
|
+
"Tag membership is removed from every tagged issue and "
|
|
236
|
+
"article; recreating the tag does not restore assignments. "
|
|
237
|
+
"Full recovery requires a database backup restore."
|
|
238
|
+
),
|
|
239
|
+
)
|
|
216
240
|
client.tags.delete(name)
|
|
217
241
|
return {"ok": True, "action": "delete", "tag": name}
|
|
218
242
|
|
|
@@ -9,8 +9,13 @@ from __future__ import annotations
|
|
|
9
9
|
from typing import Any
|
|
10
10
|
|
|
11
11
|
from kd.cli.core.command_base import Command, CommandResult
|
|
12
|
+
from kd.cli.core.confirm import require_confirm
|
|
12
13
|
from kd.cli.core.namespaces import Namespace
|
|
13
|
-
from kd.cli.core.option_registry import
|
|
14
|
+
from kd.cli.core.option_registry import (
|
|
15
|
+
OptionDeclaration,
|
|
16
|
+
OptionLayer,
|
|
17
|
+
ResolvedOptions,
|
|
18
|
+
)
|
|
14
19
|
from kd.exceptions import ValidationError
|
|
15
20
|
|
|
16
21
|
|
|
@@ -77,17 +82,42 @@ class UserDeleteCommand(Command):
|
|
|
77
82
|
"Delete a user",
|
|
78
83
|
requires_client=True,
|
|
79
84
|
usage="kd /user delete HUB_USER_ID",
|
|
80
|
-
examples=["kd /user delete abc-123"],
|
|
85
|
+
examples=["kd /user delete abc-123 --confirm"],
|
|
81
86
|
see_also=["/user list"],
|
|
82
87
|
)
|
|
88
|
+
self.register_option(
|
|
89
|
+
OptionDeclaration(
|
|
90
|
+
name="confirm",
|
|
91
|
+
layer=OptionLayer.COMMAND,
|
|
92
|
+
type=bool,
|
|
93
|
+
default=False,
|
|
94
|
+
help_text=(
|
|
95
|
+
"Required — user delete is not recoverable from Deleted "
|
|
96
|
+
"Items (consider banning via the Hub UI instead)"
|
|
97
|
+
),
|
|
98
|
+
hidden_from_reference=True,
|
|
99
|
+
)
|
|
100
|
+
)
|
|
83
101
|
|
|
84
102
|
def execute(
|
|
85
103
|
self, args: list[str], options: ResolvedOptions, client: Any = None
|
|
86
104
|
) -> CommandResult:
|
|
87
105
|
if not args:
|
|
88
106
|
raise ValidationError("Usage: kd /user delete HUB_USER_ID")
|
|
89
|
-
|
|
90
|
-
|
|
107
|
+
user_id = args[0]
|
|
108
|
+
require_confirm(
|
|
109
|
+
confirmed=bool(options.command.get("confirm")),
|
|
110
|
+
command="/user delete",
|
|
111
|
+
entity_id=user_id,
|
|
112
|
+
caveat=(
|
|
113
|
+
"Identity references in issue history become detached, and "
|
|
114
|
+
"the account is removed from the Hub. Consider banning the "
|
|
115
|
+
"user in the Hub UI instead; full recovery requires a "
|
|
116
|
+
"database backup restore."
|
|
117
|
+
),
|
|
118
|
+
)
|
|
119
|
+
client.users.delete(user_id)
|
|
120
|
+
return {"ok": True, "action": "delete", "user": user_id}
|
|
91
121
|
|
|
92
122
|
|
|
93
123
|
def create_user_namespace() -> Namespace:
|
|
@@ -10,6 +10,7 @@ knowledge). The file is created lazily on first write operation.
|
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
+
import importlib.resources
|
|
13
14
|
from pathlib import Path
|
|
14
15
|
from typing import Any
|
|
15
16
|
|
|
@@ -283,3 +284,49 @@ def clear_tags(path: Path | None = None) -> int:
|
|
|
283
284
|
data.tags.clear()
|
|
284
285
|
save_primer(data, primer_file)
|
|
285
286
|
return count
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
# ---------------------------------------------------------------------------
|
|
290
|
+
# Scaffolding
|
|
291
|
+
# ---------------------------------------------------------------------------
|
|
292
|
+
|
|
293
|
+
_PRIMER_TEMPLATE_PACKAGE = "kd.resources.primers"
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def list_primer_templates() -> list[str]:
|
|
297
|
+
"""Return sorted names of shipped primer templates (without ``.yaml``)."""
|
|
298
|
+
root = importlib.resources.files(_PRIMER_TEMPLATE_PACKAGE)
|
|
299
|
+
return sorted(p.name[: -len(".yaml")] for p in root.iterdir() if p.name.endswith(".yaml"))
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def init_primer(template: str = "hitl", path: Path | None = None) -> Path:
|
|
303
|
+
"""Scaffold ``.kd/primer.yaml`` from a packaged template.
|
|
304
|
+
|
|
305
|
+
Copies the template file through unchanged so its banner and inline
|
|
306
|
+
comments survive; no YAML load/dump round-trip. Refuses if a primer
|
|
307
|
+
already exists — deletion is explicit operator work and there is no
|
|
308
|
+
``--force``.
|
|
309
|
+
"""
|
|
310
|
+
from kd.history import atomic_write_text
|
|
311
|
+
|
|
312
|
+
available = list_primer_templates()
|
|
313
|
+
if template not in available:
|
|
314
|
+
raise ValidationError(
|
|
315
|
+
f"Unknown primer template '{template}'. Available: {', '.join(available)}"
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
primer_file = path or _primer_path()
|
|
319
|
+
if primer_file.exists():
|
|
320
|
+
raise ValidationError(
|
|
321
|
+
f"Primer already exists at {primer_file}. "
|
|
322
|
+
f"Run `kd /primer show` to inspect it, or delete the file to start over."
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
content = (
|
|
326
|
+
importlib.resources.files(_PRIMER_TEMPLATE_PACKAGE)
|
|
327
|
+
.joinpath(f"{template}.yaml")
|
|
328
|
+
.read_text(encoding="utf-8")
|
|
329
|
+
)
|
|
330
|
+
primer_file.parent.mkdir(parents=True, exist_ok=True)
|
|
331
|
+
atomic_write_text(primer_file, content)
|
|
332
|
+
return primer_file
|
|
@@ -4,6 +4,12 @@ All notable changes to kd-cli are recorded here. The project follows [Semantic V
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [2.4.0] — 2026-04-19
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- `kd /primer init [TEMPLATE]` scaffolds `.kd/primer.yaml` from a packaged template so fresh workspaces don't start from a blank page. The default `hitl` template ships placeholder prose in three slots (scope guard, session workflow, canonical reference); the banner and example-shape comments are preserved verbatim. Refuses if a primer already exists; unknown template names reject with the available-templates list (KDCLI-97).
|
|
11
|
+
- `--confirm` flag on `/project delete`, `/tag delete`, and `/user delete` — these three deletes bypass YouTrack's Deleted Items and require a backup restore to undo, so kd now rejects them without `--confirm` and prints the literal retry command in the error. The flag is hidden from `kd --reference` but visible in per-command `--help` (KDCLI-96).
|
|
12
|
+
|
|
7
13
|
## [2.3.0] — 2026-04-18
|
|
8
14
|
|
|
9
15
|
### Added
|
|
@@ -82,6 +82,14 @@ kd /issue update KDCLI-42 --state Fixed -o yaml
|
|
|
82
82
|
For article push, use `--dry-run` before a risky write and inspect conflicts with `/article pull`.
|
|
83
83
|
`/article push --tag` rejects missing tags by default and prints the concrete recovery commands. Use `--create-tags` only for scripted flows that already own the tag namespace.
|
|
84
84
|
|
|
85
|
+
Three delete commands bypass YouTrack's Deleted Items safety net and require an explicit `--confirm` flag:
|
|
86
|
+
|
|
87
|
+
- `/project delete` — all issues and articles in the project are permanently removed, not moved to Deleted Items.
|
|
88
|
+
- `/tag delete` — tag membership is lost across every tagged issue and article; recreating the tag does not restore assignments.
|
|
89
|
+
- `/user delete` — identity references in issue history become detached; consider banning in the Hub UI instead.
|
|
90
|
+
|
|
91
|
+
Without `--confirm` these commands exit non-zero with an error that names the failure mode and prints the literal retry command. Recovery for any of the three requires a database backup restore. `/issue delete`, `/article delete`, and attachment deletes do not require `--confirm` — they go to Deleted Items and are admin-restorable for roughly 14 days.
|
|
92
|
+
|
|
85
93
|
## YouTrack Gotchas
|
|
86
94
|
|
|
87
95
|
YouTrack articles are not queryable like issues. `/api/articles` has no issue-style `query` parameter, and there is no server-side article-by-tag endpoint. kd article tag lookup scans article pages that include `tags(id,name)` and filters locally.
|
|
@@ -106,6 +114,8 @@ Tag existence, tag visibility, and tag sharing rights are different concerns. A
|
|
|
106
114
|
|
|
107
115
|
## Primer Practices
|
|
108
116
|
|
|
117
|
+
For a fresh workspace, scaffold the primer with `kd /primer init`. The default `hitl` template drops placeholder prose into three slots — scope guard, session workflow, canonical reference — that the operator fills in an editor. The command refuses if a primer already exists and has no `--force`; deletion is explicit operator work.
|
|
118
|
+
|
|
109
119
|
Primer notes should capture durable project rules, not temporary status. Good notes explain naming conventions, required workflows, dangerous assumptions, and pointers to canonical references.
|
|
110
120
|
|
|
111
121
|
Do not use the primer as a session log. Avoid recording current focus, completed session lists, release-cadence details copied from a plan, or other progress facts that can become false by the next agent session. If the primer needs to point at active work, stop at the current master plan or equivalent planning document; the agent should open that document and derive the next step from there.
|
|
@@ -211,4 +221,4 @@ Use these sources together:
|
|
|
211
221
|
- `docs/design/architecture.md` and ADRs for architectural constraints.
|
|
212
222
|
|
|
213
223
|
---
|
|
214
|
-
Updated: 2026-04-
|
|
224
|
+
Updated: 2026-04-19
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# DO NOT EDIT THIS FILE DIRECTLY. Use `kd /primer --help` to manage it.
|
|
2
|
+
#
|
|
3
|
+
# This is the `hitl` template — human-in-the-loop session workflow. Edit the
|
|
4
|
+
# placeholders below to fit this workspace. Three slots:
|
|
5
|
+
# 1. Scope guard — what this workspace is / is not; how to reject drift.
|
|
6
|
+
# 2. Session workflow — the repeatable loop and local conventions.
|
|
7
|
+
# 3. Canonical reference — pinned article(s) with durable background.
|
|
8
|
+
|
|
9
|
+
notes:
|
|
10
|
+
- '<WORKSPACE> is <one-sentence identity: what kind of tool, codebase, or knowledge
|
|
11
|
+
base this workspace represents>. Primary loop: <describe the repeatable action —
|
|
12
|
+
for example, pull context → reason → push focused updates back>. <State what this
|
|
13
|
+
workspace is NOT — adjacent shapes it should not drift toward, such as migration
|
|
14
|
+
platform, data warehouse, silent local mirror>. Before adding features that look
|
|
15
|
+
like the adjacent shape, re-read this guard. Test question: does this keep the
|
|
16
|
+
workspace <identity>-shaped, or does it drag it toward <adjacent shape>? Reject
|
|
17
|
+
drift toward the latter.'
|
|
18
|
+
- 'Active planning entry point: <path to master plan, roadmap doc, or tracking
|
|
19
|
+
project>. The primer must not record session-level progress, current focus,
|
|
20
|
+
completed-session lists, or release-cadence details copied from the plan; those
|
|
21
|
+
stale quickly. A fresh agent reads this pointer, checks the active plan or
|
|
22
|
+
assigned ticket for scope, then follows the default session workflow recorded
|
|
23
|
+
in this primer.'
|
|
24
|
+
- 'Default session workflow: 1) Load primer with `kd /primer show -o yaml`. 2) Read
|
|
25
|
+
the assigned ticket or active planning source; if tracked work lacks a ticket,
|
|
26
|
+
create one with `kd /issue create ... --project <PROJECT> --type <Feature|Bug|Task>`
|
|
27
|
+
and use the returned ID. 3) Enter plan mode for a full tracked session and write
|
|
28
|
+
the session doc from the local template, naming the file with the ticket ID when
|
|
29
|
+
present. 4) Execute code, tests, and docs together; run the project''s test, lint,
|
|
30
|
+
and type checks before commit. 5) Commit with `<TICKET-PREFIX>-NN: <subject>` for
|
|
31
|
+
tracked work. 6) Install the built artifact, run applicable HITL against a real
|
|
32
|
+
target, append the session conclusion, comment on the ticket, transition it to
|
|
33
|
+
<done-state>, and update the relevant plan and docs. If no ticket or user-visible
|
|
34
|
+
HITL surface exists, record that explicitly in the session doc.'
|
|
35
|
+
|
|
36
|
+
tags: []
|
|
37
|
+
|
|
38
|
+
# Pin canonical reference articles after `kd /primer init`. Example shape:
|
|
39
|
+
# - id: <ARTICLE-ID>
|
|
40
|
+
# summary: <one-line hook — what this pinned article gives the operator>
|
|
41
|
+
articles: []
|
|
@@ -32,6 +32,7 @@ kd/cli/tree.py
|
|
|
32
32
|
kd/cli/core/__init__.py
|
|
33
33
|
kd/cli/core/command_base.py
|
|
34
34
|
kd/cli/core/command_parser.py
|
|
35
|
+
kd/cli/core/confirm.py
|
|
35
36
|
kd/cli/core/namespaces.py
|
|
36
37
|
kd/cli/core/option_registry.py
|
|
37
38
|
kd/cli/namespaces/__init__.py
|
|
@@ -68,6 +69,8 @@ kd/resources/command-synonyms.yaml
|
|
|
68
69
|
kd/resources/config-template.yaml
|
|
69
70
|
kd/resources/error-messages.yaml
|
|
70
71
|
kd/resources/operating-guide.md
|
|
72
|
+
kd/resources/primers/__init__.py
|
|
73
|
+
kd/resources/primers/hitl.yaml
|
|
71
74
|
kd_cli.egg-info/PKG-INFO
|
|
72
75
|
kd_cli.egg-info/SOURCES.txt
|
|
73
76
|
kd_cli.egg-info/dependency_links.txt
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "kd-cli"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.4.0"
|
|
8
8
|
description = "Knowledge Dispatcher for issue trackers and knowledge bases"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -57,7 +57,7 @@ kd = "kd.cli.main:main"
|
|
|
57
57
|
include = ["kd*"]
|
|
58
58
|
|
|
59
59
|
[tool.setuptools.package-data]
|
|
60
|
-
kd = ["resources/*.yaml", "resources/*.md"]
|
|
60
|
+
kd = ["resources/*.yaml", "resources/*.md", "resources/primers/*.yaml"]
|
|
61
61
|
|
|
62
62
|
[tool.ruff]
|
|
63
63
|
exclude = ["docs"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|