# hired.cli

Command-line operations for the candidate-knowledge + JD-alignment workflow.

Each function here is a plain, importable operation — no CLI library is imported —
and [`CLI_FUNCS`](#hired.cli.CLI_FUNCS) is the single source of truth for what the `hired` command
exposes (see `hired.__main__`, which projects it onto a parser with `cw`).

Every operation takes a keyword-only `user` (`--user` on the command line),
resolved by [`hired.persistence.resolve_user()`](hired.persistence.html.md#hired.persistence.resolve_user): the given name, else
`$HIRED_USER`, else `"me"`. So a single-candidate setup needs no flag at all,
and several candidates coexist under `users/<user>/`.

The *intelligence* stays outside: `ingest` takes fact records an extractor (the
`hired-profile-ingest` subagent, or an LLM) already produced, and `analyze`
takes an analyst-drafted report; the commands validate, derive what is
deterministic, and persist. `align` is the one exception: it runs the
injected-LLM analyzer ([`hired.alignment.analyzer`](hired.alignment.analyzer.html.md#module-hired.alignment.analyzer)) on raw JD text.

```pycon
>>> import os, json, tempfile
>>> os.environ['HIRED_DATA_DIR'] = tempfile.mkdtemp()
>>> work = tempfile.mkdtemp()
>>> cv = os.path.join(work, 'cv.md')
>>> _ = open(cv, 'w').write('I built ML pipelines in Python.')
>>> recs = os.path.join(work, 'facts.json')
>>> _ = open(recs, 'w').write(json.dumps([{'statement': 'Builds ML pipelines',
...     'category': 'skill', 'quote': 'built ML pipelines'}]))
>>> ingest(recs, source=cv, user='alice')['added']
1
>>> users()
['alice']
>>> facts(user='alice')
['Builds ML pipelines']
```

### Module Attributes

| [`CLI_FUNCS`](#hired.cli.CLI_FUNCS)   | The operations the `hired` command exposes (SSOT for every surface).   |
|--------------------------------------------------------------|------------------------------------------------------------------------|

### Functions

| [`add_source`](#hired.cli.add_source)(path, \*[, name, user])                 | Store a raw source document (CV, bio, publication list...) for a candidate.            |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| [`align`](#hired.cli.align)(jd, \*, jd_text[, job_id, job_title, ...])   | Analyse a raw job description (the file `jd_text`) with an LLM and save the report.    |
| [`analyze`](#hired.cli.analyze)(report, jd, \*[, job_id, company, user])   | Finalize an analyst-drafted alignment report (JSON) and save it under engagement `jd`. |
| [`build_skill_index`](#hired.cli.build_skill_index)(\*[, embeddings, no_onet, ...])  | Download ESCO (+ O\*NET) and build the skill-adjacency taxonomy (tens of minutes).     |
| [`facts`](#hired.cli.facts)(\*[, category, tag, user])                   | List a candidate's current (asserted) fact statements.                                 |
| [`ingest`](#hired.cli.ingest)(records, \*[, source, user])                | Add extracted fact records (a JSON list) to a candidate's knowledge base.              |
| [`jds`](#hired.cli.jds)(\*[, user])                                    | List a candidate's engagements (one per company; 1+ roles each).                       |
| [`report`](#hired.cli.report)(jd[, job_id, fmt, output, user])            | Render a saved alignment report (`--fmt markdown|html`).                               |
| [`reports`](#hired.cli.reports)(jd, \*[, user])                            | List the job ids that have an alignment report in engagement `jd`.                     |
| [`skill_adjacency`](#hired.cli.skill_adjacency)(requirement, candidate_skills, \*) | Rank the candidate's skills (comma-separated) by adjacency to `requirement`.           |
| [`skill_lookup`](#hired.cli.skill_lookup)(text, \*[, k])                        | Taxonomy skills matching `text` (score, how matched, label, source, id).               |
| [`status`](#hired.cli.status)(\*[, user])                                 | Summarize a candidate's knowledge base: counts, pending material, engagements.         |
| [`synopsis`](#hired.cli.synopsis)(\*[, regenerate, user])                   | Print a candidate's synopsis (`--regenerate` rebuilds it from the facts).              |
| [`users`](#hired.cli.users)()                                            | List the candidates that have data (one `users/<user>/` directory each).               |

### hired.cli.CLI_FUNCS *= [<function users>, <function status>, <function add_source>, <function ingest>, <function facts>, <function synopsis>, <function jds>, <function analyze>, <function align>, <function reports>, <function report>, <function build_skill_index>, <function skill_lookup>, <function skill_adjacency>]*

The operations the `hired` command exposes (SSOT for every surface).

### hired.cli.add_source(path, , name=None, user=None)

Store a raw source document (CV, bio, publication list…) for a candidate.

Prints the source key. Its facts are added later with `ingest`.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### hired.cli.align(jd, , jd_text, job_id=None, job_title='', company=None, model=None, n_samples=1, nli=False, user=None)

Analyse a raw job description (the file `jd_text`) with an LLM and save the report.

The autonomous counterpart of `analyze`: an LLM (the `ai` extra, an
`OPENAI_API_KEY`) decomposes the JD and judges each requirement against the
candidate’s facts, every judgment must quote a fact verbatim, and the verdict
is computed deterministically. The JD text is stored as the job under
engagement `jd`. `job_id` defaults to the file’s name without extension;
`--n-samples` > 1 samples each judgment for calibrated confidence; `--nli`
adds an entailment check on every match.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### hired.cli.analyze(report, jd, , job_id=None, company=None, user=None)

Finalize an analyst-drafted alignment report (JSON) and save it under engagement `jd`.

Every requirement is re-classified with the deterministic rubric, bucket
counts, blocking gaps and the ranked clarifying questions are rebuilt, and
the report is saved (the previous version of the same job’s report is
archived). Prints the saved job id and the resulting verdict line.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### hired.cli.build_skill_index(, embeddings=False, no_onet=False, refresh=False)

Download ESCO (+ O\*NET) and build the skill-adjacency taxonomy (tens of minutes).

`--embeddings` also embeds every label (needs `hired[embeddings]`);
`--refresh` re-downloads instead of reusing cached pages. The data and its
CC BY 4.0 attribution (`NOTICE.md`) go under `<data root>/taxonomy/`.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

### hired.cli.facts(, category=None, tag=None, user=None)

List a candidate’s current (asserted) fact statements.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### hired.cli.ingest(records, , source=None, user=None)

Add extracted fact records (a JSON list) to a candidate’s knowledge base.

`records` is a JSON file holding a list of `{"statement", "category",
"tags", "confidence", "quote", "locator", "is_negation"}` dicts. With
`--source` (a raw-source key, or a file path, which is stored first) the
facts cite that source, their quotes are checked against its text, and a
re-ingest of the same source supersedes the facts of the previous one.
Without it, the facts are recorded as externally sourced.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

### hired.cli.jds(, user=None)

List a candidate’s engagements (one per company; 1+ roles each).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### hired.cli.report(jd, job_id=None, , fmt='markdown', output=None, user=None)

Render a saved alignment report (`--fmt markdown|html`).

`job_id` may be omitted when the engagement has a single report. With
`--output` the rendering is written to that file (and its path printed);
otherwise it is printed.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### hired.cli.reports(jd, , user=None)

List the job ids that have an alignment report in engagement `jd`.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### hired.cli.skill_adjacency(requirement, candidate_skills, , k=3, alpha=0.5)

Rank the candidate’s skills (comma-separated) by adjacency to `requirement`.

Each line: blended score, suggested transferability band, and the evidence
(shared taxonomy neighbour, relatedness, label similarity).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### hired.cli.skill_lookup(text, , k=5)

Taxonomy skills matching `text` (score, how matched, label, source, id).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### hired.cli.status(, user=None)

Summarize a candidate’s knowledge base: counts, pending material, engagements.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

### hired.cli.synopsis(, regenerate=False, user=None)

Print a candidate’s synopsis (`--regenerate` rebuilds it from the facts).

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### hired.cli.users()

List the candidates that have data (one `users/<user>/` directory each).

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
