@softure-ai/skills 0.19.0 → 0.20.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.
package/ONBOARD.md CHANGED
@@ -81,7 +81,7 @@ you escalate. Talk to me in <chat language>; everything you write to the reposit
81
81
  filed in SOFTURE/SKILLS; only a release or a production deploy waits for my word;
82
82
  - for a hosted project (claude.ai project) whose instructions lack it, the pointer from
83
83
  WORKFLOW §8.5 with <owner>/<repo> filled in, ready to paste.
84
- 6. Then follow "Start of a run" from AGENTS.md: adopt what is in flight first (give the go to READY
84
+ 6. Then follow "Start of a run" from AGENTS.md: act on open `owner-word` issues first, then adopt what is in flight (give the go to READY
85
85
  threads, nudge stalled ones), then start threads for ready, parallel-safe items, then the report
86
86
  routine. With no roadmap and no issue queue, say so in one line and name what I give next (a
87
87
  goal for `softure-shape`, or an issue queue); do not invent work.
package/README.md CHANGED
@@ -24,10 +24,34 @@ What the installer does (idempotent; re-run on every `npm install`):
24
24
  | `rules/AGENTS.md` | managed block in `AGENTS.md` (or `CLAUDE.md` if only that exists) |
25
25
  | ignore entries | managed block in `.gitignore`: installed skills are restored by `npm install`, not committed |
26
26
  | manifest | `.claude/softure-skills.json` |
27
+ | label `owner-word` | created on the forge when an authenticated `gh` can (outside CI); otherwise the command is printed |
27
28
 
28
29
  It never overwrites a skill folder it did not install. Flags: `--dry-run`, `--target <dir>`,
29
30
  `--no-gitignore` (commit the skills instead).
30
31
 
32
+ **CI line.** Add one step to the project's CI check, documentation-only changes included:
33
+
34
+ ```bash
35
+ npx softure-skills doctor
36
+ ```
37
+
38
+ It fails on drift in `context/` (a roadmap left after its archive, archived changes not stamped,
39
+ `## Summary` placeholders, a stale `context/state.json`, …; WORKFLOW §12). The installer prints the
40
+ line until a workflow runs it. `npx softure-skills state` regenerates `context/state.json`, which the
41
+ scripts otherwise write themselves.
42
+
43
+ ## Many projects at once
44
+
45
+ `npx softure-skills portfolio` is read-only: it reads `context/state.json` from the main branch of every
46
+ listed repository (arguments, or `~/.config/softure/portfolio.json` outside any project) and prints one table:
47
+
48
+ ```
49
+ | project | active roadmap X/N | queued | open changes | owner queue | last release | doctor |
50
+ ```
51
+
52
+ `--owner` prints only what waits for the owner across all projects, oldest first; `--json` gives the same
53
+ data to another tool; `--source api` reads through the GitHub API instead of git. See WORKFLOW §12.3.
54
+
31
55
  **Operating mode.** `context/workflow.json` → `mode` is `"manual"` (default) or `"autonomous"`, and the
32
56
  installer injects only that mode's section into the rules block:
33
57
 
@@ -95,6 +119,7 @@ operating modes.
95
119
  | | `softure-lesson` | numbered rule in `lessons.md` |
96
120
  | | `softure-rule-review` | audit of AGENTS.md / CLAUDE.md / skills |
97
121
  | | `softure-evidence` | screenshots and recordings in the evidence store (never git) + the evidence page |
122
+ | | `softure-doctor` | `context/state.json` (machine-readable state, `owner_queue`) + the `context/` contract check |
98
123
 
99
124
  Every interactive skill accepts `--auto`: it decides instead of asking and records each
100
125
  decision in the artifact. The orchestrators always use it, and `mode: "autonomous"` implies it.
package/WORKFLOW.md CHANGED
@@ -25,6 +25,7 @@ hygiene (any time)
25
25
  softure-rule-review audit AI rule files (AGENTS.md, CLAUDE.md, skills) for drift and contradictions
26
26
  softure-lesson turn a repeated mistake into a numbered rule
27
27
  softure-evidence store screenshots and recordings outside git, by name, on one evidence page (§11)
28
+ softure-doctor check the context/ contract and keep context/state.json current (§12)
28
29
  ```
29
30
 
30
31
  Each step produces a durable artifact the next step reads. A step never starts without its
@@ -149,14 +150,17 @@ Parallel sessions push often, and every push can start the project's CI. The ski
149
150
  The project's side: when the git hooks already run the gates (`pre-commit`, `pre-push`), CI does not need to
150
151
  repeat them on every pushed branch. A pre-push hook needs a cheap path for a push whose changed files are all
151
152
  under `context/` (the roadmap commits of `wt-roadmap.py`): skip typecheck, lint and tests, keep the language
152
- check. Without it every stage costs a full suite, which is what `cloudState: "branch"` works around. Run CI on pull requests, on the main branch or on demand, skip changes
153
- that touch only documents, and cancel superseded runs (`concurrency`).
153
+ check. Without it every stage costs a full suite, which is what `cloudState: "branch"` works around. Run CI on pull requests, on the main branch or on demand, skip
154
+ the gates for changes that touch only documents, and cancel superseded runs (`concurrency`). The one step that
155
+ does run on documentation-only changes is `npx softure-skills doctor` (§12): it takes seconds and checks exactly
156
+ the files those changes edit.
154
157
 
155
158
  ## 3. Artifacts
156
159
 
157
160
  ```
158
161
  context/
159
162
  workflow.json
163
+ state.json machine-readable project state, written by scripts only (§12)
160
164
  foundation/
161
165
  shape-notes.md softure-shape (frontmatter: session, status, context_type: greenfield | brownfield, created, updated; optional `## Frame` from softure-frame)
162
166
  prd.md softure-prd (frontmatter: version, status: draft | accepted, context_type, source, updated)
@@ -382,13 +386,17 @@ the release keep `done_code` in the archived `## At a glance`, so the release st
382
386
  Then, in one commit (`docs(roadmap): close <slug>`):
383
387
 
384
388
  - move `roadmap.md` to `foundation/archive/<YYYY-MM-DD>-roadmap.md` (same-day collision: `-2`, `-3`, never other
385
- suffixes) and append `## Summary`: one table `| ID | Item | What changed | Merge |` (merge SHA per row) and the
386
- integration result line. It is the version history; release notes can be built from it;
389
+ suffixes) and append `## Summary`: one table `| ID | Item | What changed | Merge |` (merge SHA per row, `—` for a
390
+ carried or dropped row, never a placeholder) and the integration result line. It is the version history; release
391
+ notes can be built from it. The release that ships it may add one line `Release: <version> (<YYYY-MM-DD>)` under
392
+ the summary; `context/state.json` reports the newest one as `last_release`;
387
393
  - carried rows move to the next roadmap or to a queued one, never silently dropped;
388
394
  - if this roadmap was promoted from `roadmaps/roadmap-<slug>.md`, remove its backlog folder
389
395
  `backlog/roadmap-<slug>/` (move entries that are still alive to another queued roadmap first) and its row in an
390
396
  index file such as `foundation/roadmaps/README.md`, if the project keeps one;
391
- - afterwards: every file in `roadmaps/` is a waiting roadmap, and every folder in `backlog/` has its roadmap file.
397
+ - afterwards: every file in `roadmaps/` is a waiting roadmap, and every folder in `backlog/` has its roadmap file;
398
+ - right before the commit: `context_state.py write --staged` (the state goes into the same commit) and
399
+ `doctor.py`; a failure the close owns is fixed, any other is named in the report (§12).
392
400
 
393
401
  ## 6. `plan.md`
394
402
 
@@ -593,6 +601,25 @@ the set. It never derives the next start only from the thread that just merged.
593
601
  scoped to the project's own repository: attach a repository the run needs (for example SOFTURE/SKILLS
594
602
  to file a gap) before deciding it is out of reach.
595
603
 
604
+ ### 8.6 Owner-word issues
605
+
606
+ The owner often decides for a project from outside its chat, for example while reviewing several projects at once
607
+ (`softure-skills portfolio --owner`, §12.3). Such a decision travels as an issue in the project's own repository,
608
+ labelled **`owner-word`**: one decision, its scope and any limit ("start the queued roadmap payments", "release only
609
+ after the last item", "drop SA-12"). It is the owner's word in writing, equal to the same sentence in the main chat.
610
+
611
+ - **Label.** The installer creates `owner-word` when the forge allows it (GitHub through an authenticated `gh`,
612
+ outside CI); otherwise it prints the one command that creates it.
613
+ - **Autonomous mode.** The coordinator lists open `owner-word` issues first at the start of a run and again on every
614
+ report and wake-up, and acts on each like an order in the chat: a roadmap to start goes through a roadmap thread,
615
+ a release word is recorded where the release rules look for it, a "no" or "later" is recorded in the roadmap. It
616
+ comments what it did (thread, PR, merge SHA) and closes the issue; one it cannot act on (unclear, contradicts
617
+ `change.md` or a standing order) gets a comment with the question and stays open.
618
+ - **Manual mode.** The coordinator shows open `owner-word` issues to the owner at the start of a session and acts
619
+ only on the owner's word in the conversation; it then comments and closes them the same way.
620
+ - **Not in `state.json`.** Open owner-word issues live on the forge; an aggregator reads both (`state.json` for what
621
+ waits for the owner, the forge for the words already given).
622
+
596
623
  ## 9. Commits
597
624
 
598
625
  - Implementation: `<type>(<change-id>): <phase title> (p<N>)`. Type is `feat`, `fix`, `refactor`,
@@ -600,7 +627,7 @@ to file a gap) before deciding it is out of reach.
600
627
  - Review fixes: `fix(<change-id>): address impl review`.
601
628
  - Progress bookkeeping (when no later commit of the change carries it): `docs(<change-id>): progress p<N>`.
602
629
  - Archive: `chore(archive): close <change-id>`.
603
- - Roadmap stage updates: `docs(roadmap): <ID> <stage>`.
630
+ - Roadmap stage updates: `docs(roadmap): <ID> <stage>` (they carry `context/state.json`, §12).
604
631
  - Lessons: `docs(lessons): L-<NNN> <title>`. Rule-file edits: `docs(rules): <what>`.
605
632
  - Merge of a worktree branch: `Merge <change-id> (<ID>): <outcome>`.
606
633
 
@@ -666,3 +693,111 @@ concepts, private data and design material, in one layout:
666
693
  `softure-evidence` (`scripts/evidence.py`) does the naming, the conversion, the store and the page:
667
694
  `save`, `list`, `render`, `check`, `prune`. Without a configured store it keeps a local copy, reports it
668
695
  as not durable, and the setup gap goes to the owner once.
696
+
697
+ ## 12. Project state (`context/state.json`) and the doctor
698
+
699
+ An owner who runs several projects reads one file per repository instead of parsing the roadmap, the queued
700
+ roadmaps, the change folders and the owner sections by hand. The same file and one check keep `context/`
701
+ from drifting out of the contract unnoticed.
702
+
703
+ ### 12.1 `context/state.json`
704
+
705
+ Written **only by scripts**, never by hand, always in the same commit as the markdown it reflects:
706
+
707
+ | Writer | When |
708
+ | --- | --- |
709
+ | `wt-roadmap.py` | every mode (`open`, `stage`, `ready`, `done`, `done_code`), together with `roadmap.md` |
710
+ | `softure-archive` | on the main branch, before its commit (with `--handoff` the branch leaves it alone; `wt-roadmap.py done` writes it after the merge) |
711
+ | `softure-roadmap` | record, `--revise`, `--queue`, `--promote`, `--close`, before its commit |
712
+
713
+ The skills run `python3 .claude/skills/softure-doctor/scripts/context_state.py write --staged`: it reads what is
714
+ staged (so nobody's uncommitted edits leak in) and stages the result. By hand: `npx softure-skills state`.
715
+ A project without the file gets it from the first of these runs; nothing has to be migrated.
716
+
717
+ ```jsonc
718
+ {
719
+ "schema_version": 1,
720
+ "project": "Example clinic", // workflow.json `project`, else the roadmap's `project`
721
+ "mode": "autonomous", "main_branch": "main",
722
+ "updated_at": "2026-11-20T09:00:00Z", // changes only when the content does
723
+ "active_roadmap": { // null when there is no roadmap.md
724
+ "slug": "search", "title": "…", "status": "ready", "version": "2", "path": "context/foundation/roadmap.md",
725
+ "done": 2, "total": 5, // done = rows done or done_code (the report's X of N)
726
+ "items": [ // rows not done yet
727
+ { "id": "SR-2", "change_id": "search-titles", "outcome": "…", "status": "in_progress",
728
+ "stage": "implement 2/3", "since": "2026-11-08", "detail": "…", "prerequisites": ["SR-1"], "mode": "autonomous" }
729
+ ]
730
+ },
731
+ "queued": [ { "slug": "payments", "path": "…", "status": "waiting", "start_condition": "<trigger>",
732
+ "done": 0, "total": 1, "items": [ { "id": "PY-1", "change_id": "…", "outcome": "…", "status": "blocked" } ] } ],
733
+ "open_changes": [ { "change_id": "search-titles", "title": "…", "status": "implementing", "roadmap_item": "SR-2",
734
+ "updated": "2026-11-10", "stage": "implement 2/3" } ],
735
+ "owner_queue": [ // everything that waits for the owner, oldest first
736
+ { "kind": "decision", "source": "context/foundation/roadmap.md#Owner decisions and checks", "item": "SR-5",
737
+ "since": "2026-11-10", "text": "**SR-5**: choose the ranking provider …" }
738
+ ],
739
+ "last_release": { "version": "v1.4.0", "date": "2026-10-02", "source": "context/foundation/archive/2026-09-30-roadmap.md" }
740
+ }
741
+ ```
742
+
743
+ The schema ships with the package: `skills/softure-doctor/references/state.schema.json`.
744
+
745
+ **`owner_queue`** is the one list of what waits for the owner, from the main roadmap, the queued roadmaps and the
746
+ archived roadmaps:
747
+
748
+ | `kind` | Comes from |
749
+ | --- | --- |
750
+ | `word` | rows `done_code (…; waiting: release)` of the main roadmap (one entry: the release word); every queued roadmap (the word to start it, with its `trigger`) |
751
+ | `decision` | open `- [ ]` entries under `## Owner decisions and checks` that are not owner steps |
752
+ | `step` | `owner step:` entries and manual-mode owner checks `(Manual N.M)`; open `## Before the next release` entries; `done_code` rows waiting for an owner step that has no entry |
753
+ | `secret` | a `step` whose text names a secret, key, token, credential or password |
754
+
755
+ An archived roadmap contributes only its open checkboxes (its `## Before the next release` only until its
756
+ `## Summary` records a release). `source` is the file, `#`, and the heading; `item` the roadmap ID the entry names;
757
+ `since` the date in the entry, else the file's `updated`, and once written it is kept for that entry on every
758
+ rewrite. Owner-word issues (§8.6) live on the forge, not here.
759
+
760
+ `open_changes` and `updated_at` are refreshed on every write but never make the file stale: a change branch edits
761
+ its own `change.md` without touching `state.json`, and stays green.
762
+
763
+ ### 12.2 `softure-doctor`
764
+
765
+ `npx softure-skills doctor` (or `python3 .claude/skills/softure-doctor/scripts/doctor.py`) exits non-zero on:
766
+
767
+ | Code | Drift |
768
+ | --- | --- |
769
+ | `roadmap-archived-not-removed` | `roadmap.md` is still there although the same roadmap (slug and version) is in `foundation/archive/` |
770
+ | `roadmap-status-mismatch` | `roadmap.md` says `done` while rows are open, or `waiting` (a queued roadmap's status) |
771
+ | `archived-change-status` | an archived `change.md` whose status is not `archived` |
772
+ | `archived-change-progress` | an archived `plan.md` with unticked Automated items (open Manual items are legitimate) |
773
+ | `archived-roadmap-open-items` | an archived roadmap with rows that are not `done`, `done_code`, dropped or carried |
774
+ | `archived-roadmap-summary` | an archived roadmap whose `## Summary` merge column holds placeholders instead of SHAs |
775
+ | `queued-roadmap-done` | a queued roadmap whose rows are all done, never archived |
776
+ | `backlog-without-roadmap` | `backlog/roadmap-<slug>/` without `roadmaps/roadmap-<slug>.md` (or the promoted main roadmap) |
777
+ | `index-missing-file` | a table row of a `README.md` or `INDEX.md` under `context/` that links or names a missing file |
778
+ | `state-missing` | `context/state.json` is gone although git history holds it |
779
+ | `state-stale` | `context/state.json` does not match the markdown |
780
+
781
+ A project that has never written `state.json` gets a note, not a failure. **Adopting projects run the doctor in their
782
+ CI check**, documentation-only changes included; the installer prints the line (`npx softure-skills doctor`) until a
783
+ workflow under `.github/workflows/` runs it. `softure-archive` and `softure-roadmap --close` run it before their commit
784
+ and fix what they own.
785
+
786
+ ### 12.3 Portfolio: many projects at once
787
+
788
+ `npx softure-skills portfolio` reads the state of several projects and writes nothing anywhere (a remote is read
789
+ through a shallow, sparse clone into a temporary folder; a local checkout at `origin/<mainBranch>` without a fetch).
790
+
791
+ ```bash
792
+ npx softure-skills portfolio acme/shop ~/code/api # or list them in ~/.config/softure/portfolio.json
793
+ npx softure-skills portfolio --owner # only the owner queue, oldest first
794
+ npx softure-skills portfolio --json # the same data for another tool
795
+ ```
796
+
797
+ The config file lives outside every project (`--config <file>`, `$SOFTURE_PORTFOLIO`, default
798
+ `~/.config/softure/portfolio.json`): `{ "projects": [ { "name": "shop", "repo": "acme/shop", "branch": "main" } ] }`,
799
+ where `repo` is `owner/name`, a git URL or a local path. One row per project:
800
+ `project | active roadmap X/N | queued | open changes | owner queue | last release | doctor`. The doctor runs on the
801
+ same tree; a project without `state.json` yet gets one built in memory (marked `*`). `--source api` reads only
802
+ `state.json` through `gh api` (no doctor). Last release: `state.json` → `last_release`, else the highest `v*` tag
803
+ (the latest GitHub release with `--source api`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/skills",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "SOFTURE agent skills: a spec-driven delivery workflow (shape → prd → roadmap → plan → implement → review) plus parallel worktree orchestration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "ONBOARD.md",
16
16
  "scripts/install.mjs",
17
17
  "scripts/uninstall.mjs",
18
+ "scripts/portfolio.py",
18
19
  "README.md"
19
20
  ],
20
21
  "bin": {
package/rules/AGENTS.md CHANGED
@@ -33,7 +33,12 @@ The full contract is in `node_modules/@softure-ai/skills/WORKFLOW.md`.
33
33
  `softure-implement` → `softure-impl-review` → `softure-archive`.
34
34
  - **In parallel:** `softure-worktree` runs one change end to end in its own worktree.
35
35
  `softure-worktree-manager` runs several at once and merges them.
36
- - **Any time:** `softure-code-review`, `softure-rule-review`, `softure-lesson`.
36
+ - **Any time:** `softure-code-review`, `softure-rule-review`, `softure-lesson`, `softure-doctor`.
37
+
38
+ `context/state.json` is the machine-readable state of the project (WORKFLOW §12). Only scripts write
39
+ it (`wt-roadmap.py`, and `context_state.py write --staged` in `softure-archive` and `softure-roadmap`),
40
+ in the same commit as the markdown; never edit it by hand. CI runs `npx softure-skills doctor`, which
41
+ fails on drift in `context/`: fix the file it names, never the check.
37
42
 
38
43
  **Every change goes through the chain, however small.** A one-line fix reported in chat is a change
39
44
  too (`roadmap_item: null`). `new`, `plan`, `plan-review`, `implement`, `impl-review` and `archive` are
@@ -79,6 +84,9 @@ step the owner has to undo.
79
84
  batch before launching and asks before every merge.
80
85
  - **Questions are welcome.** When a decision is the owner's (scope, product behaviour, naming, a
81
86
  trade-off), ask with a recommendation instead of deciding silently.
87
+ - **Owner-word issues** (label `owner-word`, WORKFLOW §8.6): at the start of a session, list the open
88
+ ones in this project's repository and show them to the owner first, with what each would start. Act
89
+ on one only after the owner's word in this conversation; then comment what was done and close it.
82
90
  - Rules of autonomous projects (standing merge consent, coordinators, report cadences) do not apply
83
91
  here, even when a memory or another session suggests them.
84
92
 
@@ -133,6 +141,9 @@ the owner's to-do.
133
141
  **Start of a run.** A coordinator that wakes with no run in flight (a fresh or cleared session, or a
134
142
  hosted project's main-chat session on its first message) starts the run itself, without waiting for
135
143
  the owner's "go":
144
+ 0. **owner-word issues first:** list the open issues labelled `owner-word` in this project's repository
145
+ (through a thread when the coordinator has no forge access) and act on each before starting any other
146
+ thread (Owner-word issues, below);
136
147
  1. read `context/workflow.json` and the roadmap (or the issue queue) on the main branch; outside a
137
148
  checkout, read them, and this block, from the repository first. Then read the project's memory and
138
149
  its own coordinator conventions (the project's `AGENTS.md` outside this block). When memory lacks
@@ -189,6 +200,8 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
189
200
  - **Stale go:** a thread that got its go and has sent no merge SHA within 30 minutes is nudged at once
190
201
  (what is it waiting for, CI or a conflict?), not at the next report.
191
202
  - Posts every thread's result in the main chat as it arrives (condensed, decision first).
203
+ - **Checks open `owner-word` issues on every report and every wake-up**, before the startable set, and
204
+ acts on new ones (Owner-word issues, below).
192
205
  - **Makes sure finished threads are closed.** On every merge result, and whenever a thread with a
193
206
  one-off job hands its result over (a planning thread, the report routine setup thread once it sends
194
207
  the routine id back, a report thread), check that the thread is resolved and resolve it yourself
@@ -327,6 +340,18 @@ the owning repository first (read and issues) and only then decide you cannot fi
327
340
  of reach, put the issue text in the main chat for the owner. The work goes on around it; the item that
328
341
  needs the fix is `blocked (<repo>#<N>)`.
329
342
 
343
+ **Owner-word issues.** An open issue labelled `owner-word` in this project's repository is the owner's
344
+ word in writing, equal to the same sentence in the main chat: one decision, its scope and any limit
345
+ ("start the queued roadmap payments", "release after the last item", "drop SA-12"). The coordinator acts
346
+ on it like an order in the chat: a roadmap to start goes to a roadmap thread (`--promote`), a release
347
+ word is recorded where the release rules look for it (the roadmap header's `Release:` order, quoted with
348
+ the issue link), a "no" or "later" is recorded in the roadmap (`## Owner decisions and checks` or the
349
+ item's status). Then it comments what it did (thread, PR, merge SHA, roadmap line), closes the issue as
350
+ completed, and names it in the next report. An issue it cannot act on (unclear, contradicts `change.md`
351
+ or a standing order) gets one comment with the question and stays open; the question also goes to the
352
+ owner in the main chat. Owner-word issues are not work items: they never get a thread of their own
353
+ unless the decision itself needs one, and they are not in `context/state.json`.
354
+
330
355
  **Issues as the work source** (`autonomy.source: "issues"`, no roadmap):
331
356
  - The coordinator lists open issues (through a thread when it has no forge access). Not well-founded:
332
357
  comment why, label `invalid`, close. Well-founded: one change, one thread.
@@ -7,6 +7,11 @@
7
7
  //
8
8
  // Flags: --postinstall (never fails the host install), --dry-run, --target <dir>, --no-gitignore
9
9
  //
10
+ // Subcommands (run from the project root; Python 3, like the other scripts):
11
+ // softure-skills doctor [--json] check the context/ contract (WORKFLOW.md §12); exit 1 on drift
12
+ // softure-skills state [write|print|check] regenerate context/state.json (default: write)
13
+ // softure-skills portfolio [<repo> ...] [--owner] [--json] read-only table across many repositories
14
+ //
10
15
  // Per-project choices live in context/workflow.json -> "install" (all optional):
11
16
  // "gitignore": false commit the installed skills instead of ignoring them
12
17
  // "rules": ["workflow", ...] rule sections to inject; default: every section in RULE_SECTIONS
@@ -14,6 +19,7 @@
14
19
  // section that is always injected, whatever "rules" says. The "language" section is mandatory too:
15
20
  // only "allowNonEnglishCode": true (an owner's explicit exception) leaves it out.
16
21
 
22
+ import { spawnSync } from "node:child_process";
17
23
  import fs from "node:fs";
18
24
  import path from "node:path";
19
25
  import { fileURLToPath } from "node:url";
@@ -32,6 +38,54 @@ const RULE_SECTIONS = { language: "## Language", workflow: "## How work flows",
32
38
  const MODE_HEADING = "## Operating mode: ";
33
39
  const MODES = ["manual", "autonomous"];
34
40
  const DEFAULT_MODE = "manual";
41
+ const DOCTOR_SCRIPTS = path.join(PACKAGE_ROOT, "skills", "softure-doctor", "scripts");
42
+ // Subcommand -> [script, default arguments]. Each runs with the caller's working directory.
43
+ const SUBCOMMANDS = {
44
+ doctor: [path.join(DOCTOR_SCRIPTS, "doctor.py"), []],
45
+ state: [path.join(DOCTOR_SCRIPTS, "context_state.py"), ["write"]],
46
+ portfolio: [path.join(PACKAGE_ROOT, "scripts", "portfolio.py"), []],
47
+ };
48
+ const CI_LINE = "npx softure-skills doctor";
49
+ // Issues with this label carry an owner decision the coordinator acts on (WORKFLOW.md §8.6).
50
+ const OWNER_WORD_LABEL = {
51
+ name: "owner-word",
52
+ color: "5319e7",
53
+ description: "An owner decision the coordinator acts on (SOFTURE workflow)",
54
+ };
55
+ const LABEL_COMMAND = `gh label create ${OWNER_WORD_LABEL.name} --color ${OWNER_WORD_LABEL.color} --description "${OWNER_WORD_LABEL.description}"`;
56
+
57
+ // Creates the owner-word label on the project's forge when it can (GitHub through an authenticated gh,
58
+ // outside CI, once per checkout). Returns [action line, whether the label is known to exist].
59
+ function ensureOwnerWordLabel(projectRoot, previous, options) {
60
+ if ((previous.labels ?? []).includes(OWNER_WORD_LABEL.name)) return [null, true];
61
+ if (options.isDryRun) return [`label ${OWNER_WORD_LABEL.name} (created on the forge when gh can)`, false];
62
+ if (process.env.CI) return [null, false];
63
+ const result = spawnSync("gh", ["label", "create", OWNER_WORD_LABEL.name, "--color", OWNER_WORD_LABEL.color,
64
+ "--description", OWNER_WORD_LABEL.description], { cwd: projectRoot, encoding: "utf8", timeout: 15000 });
65
+ if (result.status === 0) return [`label ${OWNER_WORD_LABEL.name} created on the forge`, true];
66
+ if (/already exists/i.test(result.stderr ?? "")) return [null, true];
67
+ return [`label ${OWNER_WORD_LABEL.name}: not created here; run once in the repository: ${LABEL_COMMAND}`, false];
68
+ }
69
+
70
+ function runSubcommand(name, args) {
71
+ const [script, defaults] = SUBCOMMANDS[name];
72
+ const result = spawnSync("python3", [script, ...(args.length > 0 ? args : defaults)], { stdio: "inherit" });
73
+ if (result.error) {
74
+ console.error(`[softure-skills] ${name} needs python3 on PATH: ${result.error.message}`);
75
+ return 1;
76
+ }
77
+ return result.status ?? 1;
78
+ }
79
+
80
+ // True when one of the project's GitHub workflows already runs the doctor.
81
+ function hasDoctorInCi(projectRoot) {
82
+ const dir = path.join(projectRoot, ".github", "workflows");
83
+ if (!fs.existsSync(dir)) return false;
84
+ return fs
85
+ .readdirSync(dir)
86
+ .filter((name) => /\.ya?ml$/.test(name))
87
+ .some((name) => fs.readFileSync(path.join(dir, name), "utf8").includes("softure-skills doctor"));
88
+ }
35
89
 
36
90
  function parseArgs(argv) {
37
91
  const options = { isPostinstall: false, isDryRun: false, target: null, shouldIgnore: true };
@@ -199,6 +253,9 @@ function install(options) {
199
253
  }
200
254
  }
201
255
 
256
+ const [labelAction, hasLabel] = ensureOwnerWordLabel(projectRoot, previous, options);
257
+ if (labelAction) actions.push(labelAction);
258
+
202
259
  if (!options.isDryRun) {
203
260
  fs.mkdirSync(path.join(projectRoot, ".claude"), { recursive: true });
204
261
  const manifest = {
@@ -210,6 +267,7 @@ function install(options) {
210
267
  rules: ruleSections,
211
268
  mode,
212
269
  gitignore: shouldIgnore,
270
+ labels: hasLabel ? [OWNER_WORD_LABEL.name] : [],
213
271
  };
214
272
  // A re-install that changes nothing keeps the old timestamp, so a committed manifest
215
273
  // does not dirty every fresh clone or worktree after `npm ci`.
@@ -222,6 +280,14 @@ function install(options) {
222
280
  const prefix = options.isDryRun ? "[softure-skills] (dry run)" : "[softure-skills]";
223
281
  for (const action of actions) console.log(`${prefix} ${action}`);
224
282
  console.log(`${prefix} ${PACKAGE.name}@${PACKAGE.version} -> ${projectRoot}`);
283
+ if (!hasDoctorInCi(projectRoot)) {
284
+ console.log(`${prefix} CI: add \`${CI_LINE}\` to the project's CI check, documentation-only changes included (WORKFLOW.md §12)`);
285
+ }
286
+ }
287
+
288
+ const [subcommand, ...subcommandArgs] = process.argv.slice(2);
289
+ if (subcommand in SUBCOMMANDS) {
290
+ process.exit(runSubcommand(subcommand, subcommandArgs));
225
291
  }
226
292
 
227
293
  try {
@@ -233,4 +299,4 @@ try {
233
299
  process.exit(isPostinstall ? 0 : 1);
234
300
  }
235
301
 
236
- export { replaceManagedBlock, selectRuleSections };
302
+ export { CI_LINE, OWNER_WORD_LABEL, replaceManagedBlock, selectRuleSections };