@uniqbit/mate-core 0.18.3-canary.0 → 0.18.3
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/claude-plugin/hooks/hooks.json +10 -1
- package/claude-plugin/hooks/session-banner.mjs +4 -3
- package/claude-plugin/hooks/session-prepare.mjs +9 -0
- package/opencode-plugin/src/companion.ts +47 -12
- package/opencode-plugin/src/server.ts +39 -4
- package/package.json +3 -3
- package/src/cli/commands/artifact/finish/openspec.ts +1 -1
- package/src/cli/commands/artifact/pending/discovery.ts +60 -21
- package/src/cli/commands/companion/link.ts +16 -11
- package/src/cli/commands/companion/list.ts +4 -5
- package/src/cli/commands/companion/open.ts +4 -5
- package/src/cli/commands/companion/tui.ts +1 -1
- package/src/cli/commands/doctor.ts +1 -1
- package/src/cli/commands/report/renderer.ts +9 -19
- package/src/cli/commands/session/prepare.ts +119 -0
- package/src/cli/commands/shared/companion-selection.ts +2 -2
- package/src/cli/commands/studio/reports.ts +0 -1
- package/src/cli/commands/studio/server.ts +6 -2
- package/src/cli/commands/unwrap.ts +28 -3
- package/src/cli/commands/wrap.ts +53 -59
- package/src/cli/companion-selector.tsx +1 -1
- package/src/cli/main.ts +17 -0
- package/src/cli/usage.ts +3 -1
- package/src/hooks/session-banner.ts +19 -10
- package/src/hooks/session-prepare.ts +101 -0
- package/src/lib/fs-utils.ts +13 -0
- package/src/lib/orchestrator/adapters/base.ts +43 -8
- package/src/lib/orchestrator/adapters/claude.ts +130 -29
- package/src/lib/orchestrator/adapters/opencode.ts +17 -19
- package/src/lib/orchestrator/companion-git-sync.ts +28 -1
- package/src/lib/orchestrator/companion-hub.ts +2 -1
- package/src/lib/orchestrator/config-store.ts +56 -2
- package/src/lib/orchestrator/framework-context.ts +5 -29
- package/src/lib/orchestrator/launcher.ts +36 -171
- package/src/lib/orchestrator/projection-claude-entry.ts +17 -6
- package/src/lib/orchestrator/projection-claude-skills.ts +54 -22
- package/src/lib/orchestrator/projection-entries.ts +78 -11
- package/src/lib/orchestrator/projection-opencode-copies.ts +230 -0
- package/src/lib/orchestrator/projection-record.ts +7 -1
- package/src/lib/orchestrator/projection-runtime-documents.ts +83 -130
- package/src/lib/orchestrator/projection-types.ts +38 -33
- package/src/lib/orchestrator/repository-link.ts +473 -0
- package/src/lib/orchestrator/root-context.ts +6 -2
- package/src/lib/orchestrator/session-prepare.ts +425 -0
- package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
- package/src/lib/orchestrator/setup-preflight.ts +3 -1
- package/src/lib/orchestrator/types.ts +4 -1
- package/src/lib/orchestrator/working-repo-projection.ts +71 -159
- package/src/lib/orchestrator/workspace-inventory.ts +2 -2
- package/src/lib/orchestrator/wrap-pass.ts +131 -0
- package/src/lib/runtime-directory-refresh.ts +186 -0
- package/src/lib/update-checker.ts +6 -0
- package/src/opencode/companion-hooks.ts +24 -132
- package/src/opencode/companion-policy.ts +26 -10
- package/src/opencode/index.ts +1 -7
- package/src/opencode/session-notes.ts +76 -0
- package/src/opencode/session-prepare.ts +139 -0
- package/src/opencode/tui.tsx +56 -9
- package/src/runtime/claude-delivery-plan.ts +73 -0
- package/src/runtime/claude-hook-group.ts +21 -0
- package/src/runtime/companion-lock.ts +121 -0
- package/src/runtime/companion-sync.ts +66 -9
- package/src/runtime/runtime-directory.ts +43 -0
- package/src/runtime/runtime-document-manifest.ts +335 -0
- package/src/runtime/session-prepare-runner.ts +148 -0
- package/src/runtime/wrap-state.ts +90 -0
- package/src/runtime/write-atomic.ts +27 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +2 -1
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +2 -1
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +5 -0
- package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +84 -0
- package/src/templates/capabilities/react-doctor/{skill → mate-react-doctor}/references/explain.md +18 -15
- package/src/templates/mate-skills/agents/mate-openspec-backfill/SKILL.md +45 -29
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +1 -1
- package/src/templates/mate-skills/claude/mate-openspec-backfill/SKILL.md +45 -29
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +1 -1
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +850 -499
- package/src/tools/setup/capabilities/react-doctor.ts +34 -50
- package/src/tools/setup/dynamic-plugins/hydrate.ts +1 -1
- package/src/tools/setup/engine.ts +15 -4
- package/src/tools/setup/mate.ts +1 -1
- package/src/tools/setup/providers/claude-format.ts +11 -18
- package/src/tools/setup/providers/claude-plugin-hooks.ts +61 -24
- package/src/tools/setup/providers/claude.ts +23 -6
- package/src/tools/setup/runtime-documents.ts +152 -32
- package/src/tools/setup/working-repo-local-state.ts +82 -13
- package/src/tools/setup.ts +2 -2
- package/src/lib/orchestrator/companion-registry-reader.ts +0 -37
- package/src/lib/orchestrator/companion-resolver.ts +0 -179
- package/src/lib/orchestrator/companion-store.ts +0 -94
- package/src/lib/orchestrator/repo-local-registry.ts +0 -143
- package/src/templates/capabilities/react-doctor/claude/hooks/react-doctor.sh +0 -144
- package/src/templates/capabilities/react-doctor/skill/SKILL.md +0 -51
- package/src/templates/report-assets/README.md +0 -32
- package/src/templates/report-assets/mermaid.LICENSE +0 -21
- package/src/templates/report-assets/mermaid.min.js +0 -4376
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: mate-openspec-backfill
|
|
3
|
-
description: Reverse-engineer an OpenSpec spec for one existing feature and
|
|
4
|
-
allowed-tools: Bash(openspec:*), Bash(mate:*)
|
|
3
|
+
description: Reverse-engineer an OpenSpec spec for one existing feature and write it directly to the canonical spec, ready to publish. Use when the user wants to backfill, document, or spec existing or legacy behavior that has no spec yet.
|
|
4
|
+
allowed-tools: Bash(openspec:*), Bash(mate:*), Bash(git remote:*), Bash(git diff:*)
|
|
5
5
|
license: MIT
|
|
6
6
|
compatibility: Requires the mate CLI and the openspec capability enabled.
|
|
7
7
|
metadata:
|
|
8
8
|
author: mate
|
|
9
|
-
version: "
|
|
9
|
+
version: "2.0"
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
# Mate OpenSpec Backfill
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Specify one feature that already exists in the working repository. A backfill records behavior that already shipped, so the run writes the canonical spec `openspec/specs/<capability>/spec.md` directly and leaves it uncommitted. It never creates a change and never publishes; publication happens afterwards through `mate-artifact-publish`.
|
|
15
15
|
|
|
16
16
|
## Scope rules
|
|
17
17
|
|
|
18
18
|
- **One named feature per run.** Refuse Area-wide or repository-wide sweeps; ask the user to name a single feature and run the skill once per feature.
|
|
19
|
-
- **Interactive by design.** Every ambiguity and every suspected bug becomes a user question. Do not run this skill unattended.
|
|
19
|
+
- **Interactive by design.** Every ambiguity and every suspected bug becomes a user question, and nothing is written before the user approves the review table. Do not run this skill unattended.
|
|
20
20
|
|
|
21
21
|
## Steps
|
|
22
22
|
|
|
23
|
-
1. **Scope.** Map the named feature to code: entry points, callees, tests. Use whatever exploration tooling this project has enabled (code-graph or index tools when present, otherwise search and targeted reading) — assume no specific capability is installed. Then check `openspec/specs/` for an existing capability covering this domain — prefer extending it
|
|
23
|
+
1. **Scope.** Map the named feature to code: entry points, callees, tests. Use whatever exploration tooling this project has enabled (code-graph or index tools when present, otherwise search and targeted reading) — assume no specific capability is installed. Then check `openspec/specs/` for an existing capability covering this domain — prefer extending it in place over minting a new capability id.
|
|
24
24
|
|
|
25
25
|
2. **Sweep.** Extract candidate behaviors and tag each finding:
|
|
26
26
|
- `[test-backed]` — an existing test verifies it (strongest; scenarios translate almost directly from tests)
|
|
@@ -30,38 +30,54 @@ Create a spec for one feature that already exists in the working repository. The
|
|
|
30
30
|
Every candidate requirement needs at least one citation: a test name or `file:line`. Docs and comments corroborate but never stand alone. `[inferred]` findings are not requirements — they become questions for step 3.
|
|
31
31
|
|
|
32
32
|
3. **Ask.** Batch the open questions to the user:
|
|
33
|
-
- Behavior that looks unintended → the user rules **spec the actual behavior** or **spec the intent** (
|
|
34
|
-
- `[inferred]` findings → confirm, demote to out-of-scope, or
|
|
33
|
+
- Behavior that looks unintended → the user rules **spec the actual behavior** or **spec the intent** (and the user may open a separate fix change). Suspected bugs never silently become requirements.
|
|
34
|
+
- `[inferred]` findings → confirm, demote to out-of-scope, or drop.
|
|
35
35
|
|
|
36
|
-
4. **
|
|
36
|
+
4. **Review.** Before writing any file, present every drafted requirement in one table and wait for the user's approval:
|
|
37
|
+
|
|
38
|
+
| Requirement | Evidence | Citation |
|
|
39
|
+
| ------------------------------- | --------------- | -------------------------------- |
|
|
40
|
+
| Propagates the child exit code | `[test-backed]` | `launch.test.ts` › "exits with…" |
|
|
41
|
+
| Refuses an unknown framework id | `[code-only]` | `src/launch.ts:142` |
|
|
42
|
+
|
|
43
|
+
Write only the requirements the user approves, worded as approved. A rejected requirement is not written. This table is the only place citations and evidence tags appear — they never go into the spec.
|
|
44
|
+
|
|
45
|
+
5. **Learn the spec format.** Never assume a spec format. Read it from the schema active in this OpenSpec root, so the run follows whichever workflow the project uses:
|
|
37
46
|
|
|
38
47
|
```bash
|
|
39
|
-
openspec
|
|
40
|
-
openspec status --change "backfill-spec-<capability>" --json
|
|
41
|
-
openspec instructions <artifact-id> --change "backfill-spec-<capability>" --json
|
|
48
|
+
openspec schema which <schema-name> --json
|
|
42
49
|
```
|
|
43
50
|
|
|
44
|
-
The
|
|
51
|
+
- The active schema name is the `schema:` key in `openspec/config.yaml`. When the file or key is absent, it is OpenSpec's default, `spec-driven`.
|
|
52
|
+
- In the returned `path`, read `schema.yaml` and find the artifact that generates the specs (`generates: specs/**/*.md`). Read its `instruction`, its `template` under `templates/`, and every reference file the instruction tells you to read (for example `openspec/mate-conventions.yaml`).
|
|
53
|
+
- Those sources usually describe the **delta** a change writes. You write the **canonical** spec that archive would produce from it, so apply the schema's own delta-to-canonical rules: requirement blocks go under `## Requirements` instead of `## ADDED Requirements`, and frontmatter, per-requirement markers, and `## Purpose` take the canonical shape the schema or its references define. Leave out delta-only elements such as change backlinks and change or delta tags.
|
|
54
|
+
- When a spec already exists under `openspec/specs/`, use it as a concrete example of the canonical shape, but follow the schema where the two disagree.
|
|
55
|
+
- Derive any repository identity the format needs from the Git remote (`git remote get-url origin`), and any Area or scope value from the schema's rules. Never invent a format element the schema does not define.
|
|
56
|
+
|
|
57
|
+
6. **Write.** Write the approved requirements to `openspec/specs/<capability>/spec.md` in the format from step 5.
|
|
58
|
+
|
|
59
|
+
**New capability.** Create the file with the schema's canonical frontmatter (when it defines one), a `## Purpose` section of one or two sentences, and a `## Requirements` section holding the approved requirements with their scenarios.
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
| ---------------------------------------------------------------------------------------------- | ---------------------------------- |
|
|
48
|
-
| Scope decisions and rulings from step 3 | explore-brief.md |
|
|
49
|
-
| "Documents existing behavior, no code changes" + open questions | proposal.md |
|
|
50
|
-
| `ADDED`/`MODIFIED` requirements, behavior only, one citation each | specs/ |
|
|
51
|
-
| As-built evidence dossier: entry points, test inventory, `file:line` citations per requirement | design.md |
|
|
52
|
-
| Verification checklist: one task per requirement, "confirm behavior at <citation>" | tasks.md |
|
|
61
|
+
**Existing capability.** Edit its `spec.md` in place: append new requirements under `## Requirements` and rewrite only the requirements the user's rulings change. Preserve every other requirement, the frontmatter, and the Purpose exactly.
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
In both cases every requirement you write carries each per-requirement marker the schema requires (for example an `**Area:**` marker whose value appears in the spec's frontmatter). Requirements state observable contracts, never implementation detail ("propagates the child exit code", not "uses spawnSync"). The spec contains no citations, no `file:line` references, and no evidence tags.
|
|
64
|
+
|
|
65
|
+
7. **Validate.** Run:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
openspec validate <capability> --type spec
|
|
69
|
+
```
|
|
55
70
|
|
|
56
|
-
|
|
71
|
+
Fix every reported error and re-validate until it passes. Do not hand off a spec that fails validation.
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
- Verify: `openspec-apply-change` works through tasks.md, checking each requirement against the code.
|
|
60
|
-
- Publish: `mate-artifact-publish` applies the deltas to main specs and anchors the change.
|
|
73
|
+
8. **Hand off.** Report the written path and show the uncommitted diff (`git diff -- openspec/specs/<capability>/`, or the file itself when it is new). Point the user to `mate-artifact-publish`: the spec appears there under **Drifted specs** and can be published on its own or with the rest.
|
|
61
74
|
|
|
62
75
|
## Guardrails
|
|
63
76
|
|
|
64
|
-
- Never
|
|
65
|
-
- Never
|
|
66
|
-
- Never
|
|
67
|
-
-
|
|
77
|
+
- Never create an OpenSpec change, change artifacts, or verification tasks, and never archive.
|
|
78
|
+
- Never commit, tag, push, or publish — never run `mate artifact publish`. Publication belongs to `mate-artifact-publish`.
|
|
79
|
+
- Never write any file before the user approves the review table.
|
|
80
|
+
- Never write a requirement without a citation in the review table, and never spec a suspected bug without the user's ruling.
|
|
81
|
+
- Never write citations or evidence tags into the canonical spec.
|
|
82
|
+
- Never hard-code a spec format: take it from the active schema on every run.
|
|
83
|
+
- Keep capability ids opaque kebab-case; extend existing capabilities in place before creating new ones, and never drop or reword requirements outside the named feature.
|
|
@@ -137,7 +137,7 @@ If the document fails contract validation, report the diagnostic and correct the
|
|
|
137
137
|
- Use Mermaid whenever the user asks for a diagram or the subject has meaningful control flow, sequencing, lifecycle, or relationships. A `text` payload is a deliberate fallback, not the default for runtime flows.
|
|
138
138
|
- Pick the diagram type that matches the question: `classDiagram` for structure, `sequenceDiagram` for interaction between components, `stateDiagram-v2` for lifecycles, `flowchart TD` for control flow and call trees.
|
|
139
139
|
- Keep labels short enough to read at report width. A label that needs a sentence belongs in the neighbouring `text` section.
|
|
140
|
-
- Do not use ELK-only layouts or math labels. The report
|
|
140
|
+
- Do not use ELK-only layouts or math labels. The report loads the single-file mermaid build from a CDN, which does not carry those chunks.
|
|
141
141
|
- Pair each Mermaid visual with a short neighbouring `text` section that calls out the ownership boundary or invariant the reader should notice.
|
|
142
142
|
- Prefer the `text` payload for pseudocode, shallow file trees, or cases where a picture would genuinely obscure the point.
|
|
143
143
|
|