Metadata-Version: 2.4
Name: little-sister-jira
Version: 0.1.6
Summary: Draft a Jira issue from the words written in a node's Notes tab — a little-sister surface extension.
Keywords: monitoring,status,jira,issue-tracker,little-sister
Author: Michael Meyling
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: little-sister>=0.3.23
Requires-Dist: markdown-it-py>=4.2.0
Requires-Dist: pyyaml>=6.0
Requires-Python: >=3.11
Project-URL: homepage, https://github.com/m-31/little-sister-jira
Project-URL: repository, https://github.com/m-31/little-sister-jira
Project-URL: issues, https://github.com/m-31/little-sister-jira/issues
Project-URL: changelog, https://github.com/m-31/little-sister-jira/blob/main/CHANGELOG.md
Description-Content-Type: text/markdown

# little-sister-jira

Draft a **Jira** issue from the words written in a node's *Notes* tab of
[little-sister](https://github.com/m-31/little-sister): a button after each kind's own
in the tab's form, *File in Jira ↗*, that opens Jira's own create-issue form in a new
tab, pre-filled from those words and from what the part they are about reads.

It is a **surface extension**, not a check type — it measures nothing and adds no
`type:` name. What it adds is one button in the slot little-sister declares in the
*Notes* tab: after the kind's own button in each kind's form — *Mark seen*, then *File
in Jira ↗* — so that Enter in a field still does the act, and after *On* in the small
form whoever may set no kind is given. The line beneath the button says to paste the
issue's link into the words before saving, so that the link stands with the note.

Nothing is created behind the operator's back. The button sends the form to
little-sister's draft route in a new tab, which sends that tab on to Jira's own form;
Jira renders it, the browser's Jira session decides who is filing, and nothing exists
until a human presses **Create**. The drawer and the words stay as they are. This
package stores no Jira credential and holds no token.

## The contract

- **Requires** `little-sister >= 0.3.23` — a floor, never a pin.
- **Runs on** Python **3.11 or newer** — the library's floor, not a higher
  one of its own.
- **Registers** the `jira` **configuration aspect** (`config/jira.yaml`); fills one
  template slot, `notes.actions`, with the button and the draft function beside it;
  and adds the origin of its Jira to the policy's `form-action`, since the draft leaves
  by a redirect. It registers **no check type**.
- **Ships** one command, `python -m little_sister_jira.configure`, which writes that
  file from a Jira Cloud project's answers — see **Configure**.

## Install

```toml
# your deployment's pyproject.toml — both come from the index
[project]
# Pin them. A deployment names exact versions so an upgrade is a deliberate edit
# rather than drift; a plugin is the one that declares a floor, because two plugins
# that each pinned could not be installed together.
dependencies = ["little-sister==0.3.23", "little-sister-jira==0.1.6"]
```

```python
# wsgi.py — registrations first, the app last. The order is load-bearing in both
# directions: the aspect must be declared before little-sister first scans the
# configuration directory, and the slot filled before the first render.
# `isort: off` keeps an import sorter from quietly reversing that.
# isort: off
import little_sister_jira               # noqa: F401  the aspect and its button
from little_sister.app import app
# isort: on

__all__ = ["app"]                       # without it, lint calls the app import unused
```

## Configure

From your deployment's root, give the command the address of one of your Jira Cloud
project's pages — a board, its backlog, its issue list or an issue:

```bash
python -m little_sister_jira.configure https://<your-site>.atlassian.net/jira/software/projects/<KEY>/boards/1
```

It holds no credential and signs in to nothing. It names the addresses to open in a
browser signed in to Jira and the file to save each answer as — the account and the
project first, `myself.json` and `project.json`, then, once you have chosen an issue
type, that type's create form, `fields-<KEY>-<id>.json` — and goes on when you press
Enter; where the project's answer lists no issue types, it asks for the project's list
as well, `issuetypes-<KEY>.json`. A saved file that is not the answer asked for — Jira's
login page or an error, another site's or another project's answer, part of a create
form — is named again with what is wrong with it
([ADR-0002](https://github.com/m-31/little-sister-jira/blob/v0.1.6/docs/adr/0002-a-configuration-from-a-projects-address.md)). From what Jira
answered it writes `config/jira.yaml`; it prints the file instead where `--print` asks
it to, or where your configuration has one already or names its roots in
`LITTLE_SISTER_CONFIG_DIR`, and it never replaces one. The answers stay where they were
saved — your Downloads folder, or the current directory where there is none, unless
`--answers DIR` names another — so a run for another issue type
(`--issue-type <id or name>`) asks only for that type's.

For each field the create form **requires** it writes a line by the field's kind: a
text field gets a template in `fields:`, `"{name}: {reason}"`, with its name above it; a
field with a list of values, a commented line per value with its id and label, one to
uncomment; any other kind, such as a user or a date, a comment saying a draft cannot
fill it, so Jira's form asks for it. What every draft carries anyway and what Jira gives
a default are left out. Your account id is there as a commented `reporter:` — a pinned
reporter files everyone's tickets under one name. Jira Cloud only: a site
whose `/myself` answer carries no `accountId` is refused. A create form of more fields
than one answer holds, 200, is refused too; either way nothing is written.

The endpoints it reads, for finding the ids by hand instead:
`/rest/api/3/project/<KEY>` gives `project_id` and the issue types' ids, and
`/rest/api/3/issue/createmeta/<KEY>/issuetypes/<id>` the fields that type's create form
requires. [`examples/jira.yaml`](https://github.com/m-31/little-sister-jira/blob/v0.1.6/examples/jira.yaml) is the whole shape to copy as
`config/jira.yaml`. The three ids are required; everything else has a default:

```yaml
base_url: https://<your-site>.atlassian.net
project_id: "10000"
issue_type_id: "10002"
```

`base_url` is **checked**: an http(s) URL naming a host, with no query or fragment.
The example's value is deliberately not one, so copying the file unedited is refused
at startup rather than drawing a button whose drafts go to a host which cannot resolve
— a dead button looks exactly like a working one.

| Config | Decides |
|---|---|
| `label` | the button's text, which the *Notes* tab follows with ↗. Default `File in Jira` |
| `summary_limit` | where the summary is cut with an ellipsis. Default 200; Jira's own limit is 255 |
| `url_limit` | how long the whole draft's URL may get. Default 6000 — see **Long drafts** below |
| `fields` | extra Jira fields by id, each a template over the tokens below — this is how a project's required custom field gets filled |

A field template may interpolate `{path}` `{name}` `{status}` `{observed}` `{note}`
`{reason}` `{reasons}` `{summary}` `{url}`: `{note}` the words written in the *Notes*
tab, empty where none were; `{reason}` what the part chosen reads, on one line;
`{reasons}` every line of it; and `{url}` the node's *Notes* tab. Each says its
**words**, as the summary does (**What a draft looks like**). Substitution is plain
replacement, not `str.format`: the words and a line routinely contain a brace. An
unknown token is left standing, so a typo shows up in the draft rather than vanishing
from it.

A file written while the chips stood still loads: its `actions:` block, which said
which chips were offered, is ignored and named at startup, and the file's own `label`
and `fields` are the button's.

Nothing in that file is a credential, so no secret reference is involved. Delete it
and the button simply stops appearing — a **missing or broken `config/jira.yaml`
costs the button and nothing else**, because a monitor that will not start because
an issue tracker is misconfigured has the priorities backwards. A configuration
*directory* that will not resolve is little-sister's own refusal to start, and this
package does not soften it.

## What a draft looks like

The **summary** is `<node path>: <the words' first line>`, path first, because a Jira
board shows the head of a summary and cuts the tail — so the note's first line is the
issue's title, as the line beneath the button says. It says the line's **words**, what
the page shows of it: a link's words without its address, and no marks. Where there
are no words — the small form whoever may set no kind is given sends none — it says
what the part chosen under *On* reads: a line, its words; the node failing by its own
reading, its first line; one part beneath it, that part's own path and words; several,
how many and then each, `<node path>: 3 failing: …`.

The **description** is the words, then what the part reads — a line's words, every
line of a node, several parts one after the other, a part beneath the node opening
with its path — and then where it came from: the node's path, its status, when it was
last observed, the node's **details**, the rows of its *About* card, one `key: value`
each, and last an absolute link to the node's **Notes tab**, `notes:`, since that link
is read inside Jira. Whoever comes back from the issue lands where the note is kept,
with the issue's link in it.

A draft **says what the node's page says**. Every line it carries, and the words, are
written out as little-sister's Copy document writes them: a status a line names in
braces, `{error}`, as *error ⛔*, and a link into the node's handbook,
`handbook#restart`, to its absolute address. Then each part is written for how Jira
reads it. The description is in Jira's own wiki markup — a link as `[words|address]`,
bold as `*words*`, code as `{{code}}`, a fenced block as `{noformat}` — and the summary
and a field say their words, since Jira shows both as they are written.

## Long drafts

Everything a draft carries travels in a `GET` query string, where percent-encoding
roughly triples a traceback. Forty failing findings under one critical band — what
*On* drafts on such a node when no line is chosen — reach around nine thousand
characters, and a `{reasons}` field template duplicates them on top of that. Past the
server's request-line limit the operator gets a **414 from Jira instead of a form**,
which is worse than no button because the button still looks like it works.

So the whole URL is clamped to `url_limit` (default **6000**). What gives is the
description and the configured fields, in fair shares — a short field is not cut to
make room for a traceback that is going to be cut anyway. The project ids and the
summary are never cut. A cut body says so and keeps its `notes:` link, which is what
makes cutting safe: what the part reads is one click away, and so are the words once
the note is saved. What the part reads goes first, then the words, then the details,
from the last row up; the link is the *last* thing given up, and it goes only when the
budget cannot hold even it.

A `description` set in `fields:` is **yours**: it is cut like any other field, never
replaced by the stock body.

The default leaves roughly two kilobytes under the common 8 KB request-line default
(Tomcat's `maxHttpHeaderSize`, nginx's `large_client_header_buffers`) for the cookies
and headers a logged-in Jira session sends. **The real ceiling belongs to your Jira**
and nothing here can discover it, so confirm it and set `url_limit` accordingly.

## Develop

little-sister is declared as a **floor** — the release that promised the surface
this package writes against — and a release resolves it **from the index**, like any
other dependency: a released tree carries no `[tool.uv.sources]` table, and its
`uv.lock` names the index. Working against a library that is not on the index yet
takes a redirect to the checkout beside this one:

```toml
# pyproject.toml — while the library is unreleased, and never in a release
[tool.uv.sources]
little-sister = { path = "../little-sister", editable = true }
```

The redirect leaves a second trace by itself — the next `uv run`, and the pre-commit
gate is one, rewrites `uv.lock` to name the directory — and the two go together:
while the library is unreleased both may be committed, and neither may reach a
release. uv reads the sources table of a dependency it resolves from a path or a
checkout, so a released one would be imposed on every deployment that installs this
package that way; an install from the index is unaffected. The comment on the sources
table in `pyproject.toml` says what the window costs.

```bash
uv sync
uv run ruff check
uv run shellcheck $(git ls-files -- '*.sh' 'hooks/pre-commit')
uv run mypy
uv run mypy --python-version 3.11   # against the floor, not the interpreter you have
uv run pytest -q
# The same gate runs before every commit once the hook is enabled:
git config core.hooksPath hooks
```

The tests are fixture-based; nothing in this repository calls Jira. Run them with
`uv run pytest`, not a bare `pytest`: one test probes a subprocess with no
`PYTHONPATH`, so it only finds this package where a deployment does — installed.

Two seams are worth knowing when changing it. The button is **package data** — a
Jinja file inside `src/little_sister_jira/templates/` — and a source checkout finds
it whether or not a wheel would, so a change there is worth verifying against a built
wheel rather than the checkout. And the draft leaves by a **redirect**: the button
posts the tab's form to little-sister's draft route, which answers with Jira's form,
and a Content-Security-Policy's `form-action` governs where a form's post may be
redirected, so the package adds its Jira's origin there — named by the field that
holds it, `jira.base_url`, which the library reads as it assembles the policy.

## License

MIT — see [LICENSE](https://github.com/m-31/little-sister-jira/blob/v0.1.6/LICENSE).
