@hegemonart/get-design-done 1.50.0 → 1.51.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +74 -0
- package/README.md +2 -0
- package/SKILL.md +2 -2
- package/agents/design-reflector.md +33 -0
- package/dist/claude-code/.claude/skills/apply-reflections/SKILL.md +17 -0
- package/dist/claude-code/.claude/skills/audit/SKILL.md +5 -5
- package/dist/claude-code/.claude/skills/extract-learnings/SKILL.md +16 -0
- package/dist/claude-code/.claude/skills/instinct/SKILL.md +111 -0
- package/dist/claude-code/.claude/skills/verify/SKILL.md +1 -1
- package/dist/claude-code/.claude/skills/verify/verify-procedure.md +5 -5
- package/hooks/gdd-decision-injector.js +115 -6
- package/package.json +1 -1
- package/reference/instinct-format.md +120 -0
- package/reference/registry.json +8 -1
- package/reference/schemas/events.schema.json +1 -1
- package/reference/schemas/instinct.schema.json +91 -0
- package/reference/skill-authoring-contract.md +1 -1
- package/reference/skill-graph.md +9 -1
- package/scripts/lib/instinct-store.cjs +677 -0
- package/scripts/lib/manifest/skills.json +33 -7
- package/skills/apply-reflections/SKILL.md +17 -0
- package/skills/audit/SKILL.md +5 -5
- package/skills/extract-learnings/SKILL.md +16 -0
- package/skills/instinct/SKILL.md +111 -0
- package/skills/verify/SKILL.md +1 -1
- package/skills/verify/verify-procedure.md +5 -5
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
},
|
|
6
6
|
"metadata": {
|
|
7
7
|
"description": "Get Design Done — 5-stage agent-orchestrated design pipeline with 9 connections, handoff-first workflow, bidirectional Figma write-back, 22+ specialized agents, queryable knowledge layer (intel store, dependency analysis, learnings extraction), and a self-improvement loop (reflector, frontmatter + budget feedback, global-skills layer). v1.20.0 ships the SDK foundation: gdd-state MCP server (11 typed tools), lockfile-safe STATE.md mutations, event stream, and resilience primitives (jittered-backoff, rate-guard, error-classifier, iteration-budget) for rate-limit + 429 + context-overflow recovery. Full CI/CD pipeline (Node 22/24 × Linux/macOS/Windows) and release automation (auto-tag + GitHub Release + release-time smoke test).",
|
|
8
|
-
"version": "1.
|
|
8
|
+
"version": "1.51.0"
|
|
9
9
|
},
|
|
10
10
|
"plugins": [
|
|
11
11
|
{
|
|
12
12
|
"name": "get-design-done",
|
|
13
13
|
"source": "./",
|
|
14
14
|
"description": "Agent-orchestrated 5-stage design pipeline: Brief → Explore → Plan → Design → Verify. 22+ specialized agents, 9 connections (Figma, Refero, Preview, Storybook, Chromatic, Figma Writer, Graphify, Pinterest, Claude Design), Claude Design handoff, bidirectional Figma write-back, and a queryable intel store (.design/intel/) for dependency and learnings queries. Standalone commands: style, darkmode, compare, figma-write, graphify, handoff, analyze-dependencies, skill-manifest, extract-learnings. Embeds NNG heuristics, WCAG thresholds, typographic systems, motion framework, and anti-pattern catalog. Ships with a full CI/CD pipeline (Node 22/24 × Linux/macOS/Windows) and release automation. Optimization layer (v1.0.4.1, retroactive): gdd-router + gdd-cache-manager skills, PreToolUse budget-enforcer hook, tier-aware agent frontmatter, lazy checker gates, streaming synthesizer, /gdd:warm-cache + /gdd:optimize commands, and cost telemetry at .design/telemetry/costs.jsonl — targeting 50-70% per-task token-cost reduction with no quality-floor regression. v1.20.0 SDK foundation: gdd-state MCP server (11 typed tools), lockfile-safe STATE.md mutations, event stream at .design/telemetry/events.jsonl, resilience primitives (jittered-backoff, rate-guard, error-classifier, iteration-budget) with rate-limit + 429 + context-overflow recovery, and TypeScript toolchain.",
|
|
15
|
-
"version": "1.
|
|
15
|
+
"version": "1.51.0",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "hegemonart"
|
|
18
18
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "get-design-done",
|
|
3
3
|
"short_name": "gdd",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"description": "Agent-orchestrated 5-stage design pipeline: Brief → Explore → Plan → Design → Verify.
|
|
4
|
+
"version": "1.51.0",
|
|
5
|
+
"description": "Agent-orchestrated 5-stage design pipeline: Brief → Explore → Plan → Design → Verify. 59 specialized agents, 88 skills, 41 connection integrations (Figma, Refero, Preview, Storybook, Chromatic, Graphify, Slack, Linear, Jira, Notion, and more), handoff-first workflow via Claude Design bundles, bidirectional Figma write-back (annotations, Code Connect), queryable intel store (`.design/intel/`) for O(1) design surface lookups, and self-improvement loop (reflector agent, frontmatter + budget feedback, global-skills layer at `~/.claude/gdd/global-skills/`). Standalone commands: style, darkmode, compare, figma-write, graphify, handoff, analyze-dependencies, skill-manifest, extract-learnings, reflect, apply-reflections. Embeds NNG heuristics, WCAG thresholds, typographic systems, motion framework, and anti-pattern catalog. Ships with a full CI/CD pipeline (Node 22/24 × Linux/macOS/Windows, lint + schema + frontmatter + stale-ref + shellcheck + gitleaks + injection-scan + blocking size-budget) and release automation (auto-tag + GitHub Release + release-time smoke test). Optimization layer (v1.0.4.1, retroactive): gdd-router + gdd-cache-manager skills, PreToolUse budget-enforcer hook, tier-aware agent frontmatter, lazy checker gates, streaming synthesizer, /gdd:warm-cache + /gdd:optimize commands, and cost telemetry at .design/telemetry/costs.jsonl — targeting 50-70% per-task token-cost reduction with no quality-floor regression. v1.20.0 SDK foundation: gdd-state MCP server (11 typed tools), lockfile-safe STATE.md mutations, event stream at .design/telemetry/events.jsonl, resilience primitives (jittered-backoff, rate-guard, error-classifier, iteration-budget) with rate-limit + 429 + context-overflow recovery, and TypeScript toolchain. v1.27.7 ships gdd-mcp (Phase 27.7): 12 read-only MCP tools for sub-3s priming. v1.28.0 (Phase 28): Foundational References Tier 2 — 5 new reference files (color-theory, composition, proportion-systems, i18n, contrast-advanced), 2 verifier i18n probes + 1 explore i18n-readiness probe, 12 additive cross-link insertions across 10 existing references, 2 orthogonal audit-scoring lens-tags (composition_alignment + i18n_readiness).",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "hegemonart",
|
|
8
8
|
"url": "https://github.com/hegemonart"
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,80 @@ All notable changes to get-design-done are documented here. Versions follow [sem
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [1.51.0] - 2026-06-03
|
|
8
|
+
|
|
9
|
+
### Phase 51 - Instinct-Based Learnings
|
|
10
|
+
|
|
11
|
+
GDD's reflection loop was extractive, not predictive: `/gdd:extract-learnings` wrote a prose `LEARNINGS.md` that no
|
|
12
|
+
downstream agent read. Phase 51 restructures learnings into atomic, confidence-weighted instinct units that are
|
|
13
|
+
queryable, deduplicable, promotable, and surfaced back into agent context. Adapted from ecc's continuous-learning v2
|
|
14
|
+
(project-vs-global scope). Planned and executed via the GSD pipeline (3 parallel executor subagents). No new runtime
|
|
15
|
+
dependency, no new egress.
|
|
16
|
+
|
|
17
|
+
### Breaking changes
|
|
18
|
+
|
|
19
|
+
- **Reflection output gains atomic instinct units.** `design-reflector` now emits a `## Atomic instincts` section
|
|
20
|
+
(YAML units per `reference/instinct-format.md`) alongside a `## Narrative reflection` (dual-emit for one minor
|
|
21
|
+
version), and `/gdd:apply-reflections` gains an `[INSTINCT]` proposal class (accept/reject/defer/edit). Consumers of
|
|
22
|
+
the reflection format should read both sections.
|
|
23
|
+
- **A new instinct store + schema.** `scripts/lib/instinct-store.cjs` is the source of truth (`.design/instincts/instincts.json`
|
|
24
|
+
project + `~/.claude/gdd/global-instincts.json` global); `reference/schemas/instinct.schema.json` is wired into
|
|
25
|
+
`validate:schemas` and enforces the unit shape (confidence 0.3-0.9, domain enum, scope, sha8 project_id).
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **`reference/instinct-format.md`** + **`reference/schemas/instinct.schema.json`**: the atomic instinct unit (YAML
|
|
30
|
+
frontmatter `id`/`trigger`/`confidence`/`domain`/`scope`/`project_id`/`source`/`cycles_seen`/`first_seen`/`last_seen`
|
|
31
|
+
with a prose body), the K=2/M=2 promotion gate, the Beta(2,8) prior, and TTL decay.
|
|
32
|
+
- **`scripts/lib/instinct-store.cjs`**: JSON-canonical store with OPTIONAL FTS5 acceleration via
|
|
33
|
+
`probeOptional('better-sqlite3')` (the Phase 19.5 design-search pattern, so no dependency is added). Exports
|
|
34
|
+
`add`/`list`/`query`/`get`/`promote`/`touch`/`decay`/`deriveProjectId`; atomic writes; worktree-safe.
|
|
35
|
+
- **`/gdd:instinct`** skill: `list` / `query "<keyword>"` (FTS5 or in-memory scan) / `promote <id>` (project to global,
|
|
36
|
+
gated on `cycles_seen >= 2` across `>= 2` distinct project ids; user-confirmed).
|
|
37
|
+
- **Decision-injector integration**: `gdd-decision-injector.js` surfaces a top-3 `## Relevant instincts` block in
|
|
38
|
+
agent context (non-fatal; skipped when no store is present).
|
|
39
|
+
- **TTL decay**: instincts not surfaced in 6 cycles decay (`confidence *= 0.9`); below 0.2 they archive. Wired into the
|
|
40
|
+
cleanup sweep. Three `instinct_*` event types seeded into `events.schema.json`. `extract-learnings` dual-emits.
|
|
41
|
+
|
|
42
|
+
### Notes
|
|
43
|
+
|
|
44
|
+
- 6-manifest lockstep at **v1.51.0** + `OFF_CADENCE_VERSIONS.add('1.51.0')` + 37 `manifests-version.txt` baselines.
|
|
45
|
+
Re-locked: skill-list (89), registry (176), phase-42 count (113), the events-schema sha256 snapshot,
|
|
46
|
+
resilience-primitives (40, +instinct-store.cjs), the phase-28.5 distribution + warn count (5 -> 8; apply-reflections
|
|
47
|
+
was trimmed back to <=110), skill-graph regenerated. Tarball golden 912 -> 917 (+5; the cleanup/injector/schema edits
|
|
48
|
+
are same-path).
|
|
49
|
+
- Out of scope: cross-project federation, auto-skill-generation from instincts, embedding-based clustering, cross-runtime sync.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## [1.50.1] - 2026-06-03
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
Post-release consistency sweep against the shipped v1.50.0 surface.
|
|
58
|
+
|
|
59
|
+
- **Audit terminology aligned to 7 pillars.** `design-auditor` has been a 7-pillar audit since Phase 48, but
|
|
60
|
+
`skills/audit`, `skills/verify` (+ `verify-procedure.md`), `reference/skill-authoring-contract.md`, and the
|
|
61
|
+
registry rubric description still said "6-pillar". All now read 7-pillar (the copy/visual-hierarchy/color/
|
|
62
|
+
typography/layout/experience/micro-polish set, /28). `copy-auditor`'s "the other six pillars" is correct and
|
|
63
|
+
unchanged (copy plus six others is seven).
|
|
64
|
+
- **Plugin positioning refreshed.** `.claude-plugin/plugin.json` advertised "22+ specialized agents, 9 connections";
|
|
65
|
+
it now reads the accurate **59 agents, 88 skills, 41 connection integrations**.
|
|
66
|
+
- **Composition graph seeded.** Phase 50 shipped the composition manifest infrastructure with no data, so
|
|
67
|
+
`reference/skill-graph.md` had zero edges. The true pipeline chain is now declared via `next_skills`
|
|
68
|
+
(new-project → brief → explore → plan → design → verify → ship); `validate:composition-graph` confirms it stays an
|
|
69
|
+
acyclic, dangle-free DAG.
|
|
70
|
+
- **`SKILL.md` command table** no longer lists `benchmark` twice.
|
|
71
|
+
- **Codex default prompt** uses the `/gdd-` command prefix consistently (`/gdd-brief`, `/gdd-explore`) instead of the
|
|
72
|
+
Claude-style `/gdd:` and a stray `$gdd-explore`.
|
|
73
|
+
|
|
74
|
+
### Notes
|
|
75
|
+
|
|
76
|
+
- 6-manifest lockstep at **v1.50.1** + `OFF_CADENCE_VERSIONS.add('1.50.1')` + 37 `manifests-version.txt` baselines.
|
|
77
|
+
Re-locked `verify-after.md` after the terminology fix. No new shipped files (tarball golden unchanged).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
7
81
|
## [1.50.0] - 2026-06-03
|
|
8
82
|
|
|
9
83
|
### Phase 50 - Authoring Contract v3
|
package/README.md
CHANGED
|
@@ -261,6 +261,8 @@ All 14 runtimes receive their native artifact layout (`skills/`, `command/`, `ag
|
|
|
261
261
|
|
|
262
262
|
**Authoring contract v3 (v1.50.0).** Two additions. A verb-based anti-slop rubric (`reference/anti-slop-rubric.md`) scores five orthogonal axes (Directness, Distinctness, Hierarchy, Authenticity, Density); a sum below 35/50 routes a finding to the debt crawler as `aesthetic-slop`. It rides as a lens-tag on the existing 7-pillar audit, so it catches "generically AI-default" where the pillars catch "wrong". And a machine-parseable skill-composition manifest: optional `composes_with` / `next_skills` frontmatter, a DAG validator (`validate:composition-graph` fails on cycles or dangling refs), and an auto-generated `reference/skill-graph.md`. Skill descriptions move to a multi-paragraph v3 form (`<what>. Use when <triggers>. Activates for requests involving <kw>.`) with both forms accepted during a transition window, a boilerplate-cohort lint, and a `/gdd:new-skill` scaffolder. **No new runtime dependency.**
|
|
263
263
|
|
|
264
|
+
**Instinct-based learnings (v1.51.0).** The reflection loop now produces atomic, confidence-weighted instinct units instead of prose nobody reads. Each unit (`reference/instinct-format.md`: trigger, confidence 0.3-0.9, domain, scope, project id) is stored via `scripts/lib/instinct-store.cjs` (a JSON store with optional `better-sqlite3` FTS5 acceleration, the same probe-and-fall-back pattern as cross-cycle recall, so no dependency is added). `design-reflector` dual-emits instincts plus a narrative; `/gdd:apply-reflections` accepts them; the decision-injector surfaces the top-3 relevant instincts into agent context on every design-file read; and `/gdd:instinct list|query|promote` inspects the project and global stores. A project instinct promotes to the global layer only after it recurs across at least two projects (a conservative `Beta(2,8)` prior keeps it advisory), and stale instincts decay and archive. **No new runtime dependency.**
|
|
265
|
+
|
|
264
266
|
Verify with:
|
|
265
267
|
|
|
266
268
|
```
|
package/SKILL.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: get-design-done
|
|
3
3
|
short_name: gdd
|
|
4
4
|
description: "Master design pipeline for Claude Code. 5-stage workflow: Brief → Explore → Plan → Design → Verify. Run 'brief' first in any new project to capture the design problem, then 'explore' to inventory the codebase and interview for context. Invoke without arguments for status and auto-routing."
|
|
5
|
-
argument-hint: "[brief|explore|plan|design|verify|handoff|map|next|help|status|style|darkmode|live|compare|figma-write|graphify|discuss|list-assumptions|progress|health|todo|stats|note|plant-seed|add-backlog|review-backlog|scan|discover|settings|update|reapply-patches|audit|pause|resume|new-cycle|debug|quick|new-project|complete-cycle|fast|do|ship|undo|pr-branch|sketch|sketch-wrap-up|spike|spike-wrap-up|reflect|apply-reflections|analyze-dependencies|extract-learnings|skill-manifest|pin|unpin|list-pins|new-skill|warm-cache|optimize|cache-manager|watch-authorities|check-update|benchmark|recall|timeline|continue|zoom-out]"
|
|
5
|
+
argument-hint: "[brief|explore|plan|design|verify|handoff|map|next|help|status|style|darkmode|live|compare|figma-write|graphify|discuss|list-assumptions|progress|health|todo|stats|note|plant-seed|add-backlog|review-backlog|scan|discover|settings|update|reapply-patches|audit|pause|resume|new-cycle|debug|quick|new-project|complete-cycle|fast|do|ship|undo|pr-branch|sketch|sketch-wrap-up|spike|spike-wrap-up|reflect|apply-reflections|analyze-dependencies|extract-learnings|skill-manifest|pin|unpin|list-pins|new-skill|instinct|warm-cache|optimize|cache-manager|watch-authorities|check-update|benchmark|recall|timeline|continue|zoom-out]"
|
|
6
6
|
user-invocable: true
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -94,6 +94,7 @@ Each stage produces artifacts in `.design/` inside the current project.
|
|
|
94
94
|
| `unpin <skill>` | `get-design-done:gdd-unpin` | Phase 46 - remove pinned aliases for a skill (only files carrying the gdd-pinned-skill marker) |
|
|
95
95
|
| `list-pins` | `get-design-done:gdd-list-pins` | Phase 46 - show pinned aliases per harness with their source skill and last-pinned timestamp |
|
|
96
96
|
| `new-skill <name>` | `get-design-done:gdd-new-skill` | Phase 50 - interactive scaffolder for a new Phase 28.5 + v3-compliant skill (multi-paragraph description, lifecycle stage, optional composes_with); writes source/skills/<name>/SKILL.md |
|
|
97
|
+
| `instinct [list\|query <kw>\|promote <id>]` | `get-design-done:gdd-instinct` | Phase 51 - inspect and manage atomic instinct learning units (project + global stores); list, search by keyword, or promote a vetted project instinct to global once it clears the cross-project gate |
|
|
97
98
|
| `quality-gate` | `get-design-done:quality-gate` | Phase 25 - parallel lint/type/test/visual command runner; classifies failures via quality-gate-runner agent |
|
|
98
99
|
| `turn-closeout` | `get-design-done:turn-closeout` | Phase 25 - Stop-hook mirror skill; finalizes per-turn STATE blocks and emits closeout events |
|
|
99
100
|
| `bandit-status` | `get-design-done:bandit-status` | Phase 27.5 - read-only diagnostic surface for the bandit posterior; per-(agent, bin, delegate, tier) snapshots (alpha, beta, mean, stddev, count, last-used). Use `/gdd:bandit-reset` to mutate. |
|
|
@@ -103,7 +104,6 @@ Each stage produces artifacts in `.design/` inside the current project.
|
|
|
103
104
|
| `peer-cli-add` | `get-design-done:peer-cli-add` | Phase 27 - guided ladder for adding a brand-new peer (verification ladder + adapter scaffolding + capability-matrix update) |
|
|
104
105
|
| `watch-authorities [--refresh] [--since <date>] [--feed <name>] [--schedule <cadence>]` | `get-design-done:gdd-watch-authorities` | Run design-authority-watcher - fetch curated feeds, diff snapshot, classify new entries → `.design/authority-report.md` (consumed by `/gdd:reflect`) |
|
|
105
106
|
| `benchmark <component\|--wave N\|--list\|--refresh component>` | `get-design-done:gdd-benchmark` | Harvest + synthesize per-component design specs from 18 design systems → `reference/components/<name>.md` |
|
|
106
|
-
| `benchmark <component\|--wave N\|--list\|--refresh component>` | `get-design-done:gdd-benchmark` | Harvest + synthesize per-component design specs from 18 design systems → `reference/components/<name>.md` |
|
|
107
107
|
| `export <cycle> --format html\|pdf\|notion [--pseudonymize] [--pr]` | `get-design-done:gdd-export` | Phase 35.5 - package a finished cycle's design output into a stakeholder-shareable artifact (self-contained HTML / Paged.js-print PDF / Notion page); redacts always, `--pseudonymize` masks identity for external sharing, `--pr` posts the HTML preview via pr-commenter |
|
|
108
108
|
| `bootstrap-ds [--primary <color>] [--secondary <color>] [--tone <tags>] [--framework <t>]` | `get-design-done:gdd-bootstrap-ds` | Phase 37.2 - bootstrap a design system for a GREENFIELD project (no DS): brand input → OKLCH token system (color tints + modular type + 4pt/8pt spacing + radius/motion) in 3 variants to pick, then button/input/card proof scaffolding via `ds-generator` |
|
|
109
109
|
| `rollout-status [<cycle>] [--all] [--stuck]` | `get-design-done:gdd-rollout-status` | Phase 38.5 - track a shipped cycle's production rollout (unrolled / staging-only / canary-N% / prod-100%) by reading the feature-flag service via `rollout-coordinator`; surfaces STUCK rollouts; feeds `design_arms` by deployed %. Read-only - never advances or rolls back |
|
|
@@ -257,6 +257,39 @@ Append stdout to the cycle markdown body (after Section 8 / before the Proposals
|
|
|
257
257
|
|
|
258
258
|
---
|
|
259
259
|
|
|
260
|
+
## Atomic instincts
|
|
261
|
+
|
|
262
|
+
Phase 51 adds atomic instinct units alongside the prose reflection. For each pattern you observed this cycle that is small enough to state as a single trigger plus a one-line response, emit a structured instinct unit. The narrative below stays for human reading; this section is the machine-readable twin. Both are emitted for one minor version so readers and tooling migrate together.
|
|
263
|
+
|
|
264
|
+
Emit 0 to N units. Each unit follows `reference/instinct-format.md` exactly: YAML frontmatter (`id`, `trigger`, `confidence` from 0.3 to 0.9, `domain` from the format's enum, `scope`, `project_id`, `source`, `cycles_seen`, `first_seen`, `last_seen`) plus a short body. Set `source: design-reflector`. Set `confidence` from the strength of the evidence - a pattern seen once this cycle stays near 0.3 to 0.5; a pattern that recurs across prior learnings earns more. Do not exceed 0.9.
|
|
265
|
+
|
|
266
|
+
A unit is a proposal, not a stored fact. You write the units here; the user accepts them via `{{command_prefix}}apply-reflections` (the `[INSTINCT]` class). Accepted units land in the store through `scripts/lib/instinct-store.cjs` `add(unit, { scope, baseDir })` at the emitted confidence. You never call `add()` yourself and you never write to `.design/instincts/instincts.json` directly.
|
|
267
|
+
|
|
268
|
+
Emit each unit in a fenced `yaml` block so the apply step can parse it:
|
|
269
|
+
|
|
270
|
+
```yaml
|
|
271
|
+
id: in-<short-hash>
|
|
272
|
+
trigger: <one-line condition that should fire this instinct>
|
|
273
|
+
confidence: 0.45
|
|
274
|
+
domain: <enum value from reference/instinct-format.md>
|
|
275
|
+
scope: project
|
|
276
|
+
project_id: <project id from STATE.md or deriveProjectId>
|
|
277
|
+
source: design-reflector
|
|
278
|
+
cycles_seen: 1
|
|
279
|
+
first_seen: <ISO-8601>
|
|
280
|
+
last_seen: <ISO-8601>
|
|
281
|
+
---
|
|
282
|
+
<one or two sentences: the response this instinct recommends and why>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
If no pattern this cycle is atomic enough to state as a single trigger, write one line: "No atomic instincts this cycle." and move on. Do not pad.
|
|
286
|
+
|
|
287
|
+
### Narrative reflection
|
|
288
|
+
|
|
289
|
+
Keep the prose reflection for human readers. Summarize, in two to four sentences, the through-line of this cycle: what kept recurring, what shifted, and which instinct units above you have the most confidence in. This subsection is what a person skims; the units above are what tooling consumes.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
260
293
|
## Proposals
|
|
261
294
|
|
|
262
295
|
After all sections, write a **Proposals** section. Number proposals sequentially. Every proposal must include evidence - no vague observations.
|
|
@@ -84,6 +84,23 @@ Incubator drafts authored by `scripts/lib/incubator-author.cjs` (Phase 29-04) ap
|
|
|
84
84
|
|
|
85
85
|
KFM-catalogue proposals authored by `scripts/lib/reflector-kfm-proposer.cjs` (Phase 30.5-03 D-05) appear as a 6th proposal class. Drafts at `.design/reflections/incubator/kfm-<slug>/CATALOGUE-ENTRY.md`; pre-filled 11-field schema with `TODO:` placeholders for `pattern` + `fix`. Two upstream signals share the surface (D-06): `capability_gap` clusters (≥3, no existing match) + `kfm-candidate` events (whitelist-matched articles, 1-shot). User chooses **accept** | **reject** | **defer** | **edit**. `applyAccept` appends to `reference/known-failure-modes.md` + `reference/registry.json` (`origin: incubator-kfm`); `applyReject` removes the incubator subdir; `applyDefer` stamps `deferred_until`; `applyEdit` returns the draft path for `$EDITOR`. Full procedure: `./apply-reflections-procedure.md` §[KFM-CANDIDATE].
|
|
86
86
|
|
|
87
|
+
## [INSTINCT]
|
|
88
|
+
|
|
89
|
+
Atomic instinct units emitted by `design-reflector` (and surfaced from `/gdd:extract-learnings`) appear as a distinct proposal class, alongside `[INCUBATOR]` and `[KFM-CANDIDATE]`. Each unit is a fenced `yaml` block under the reflector's `## Atomic instincts` section, shaped per `reference/instinct-format.md` (`id`, `trigger`, `confidence`, `domain`, `scope`, `project_id`, `source`, `cycles_seen`, `first_seen`, `last_seen`, plus a short body). A unit is a proposal, never a stored fact - nothing lands until the user accepts it.
|
|
90
|
+
|
|
91
|
+
Mirror the `[INCUBATOR]` flow:
|
|
92
|
+
|
|
93
|
+
1. Discover the units: parse every `yaml` block under `## Atomic instincts` in the reflections file. Skip malformed blocks (warn on stderr, keep going).
|
|
94
|
+
2. For each unit: show the parsed `trigger`, `domain`, `confidence`, and body so the user sees what would be stored.
|
|
95
|
+
3. Prompt: `(a) accept (r) reject (d) defer (e) edit (q) quit`.
|
|
96
|
+
|
|
97
|
+
**Per-action behavior:**
|
|
98
|
+
|
|
99
|
+
1. **accept** - call `scripts/lib/instinct-store.cjs` `add(unit, { scope, baseDir })` with the unit at its emitted `confidence`. The store owns de-duplication and `cycles_seen` bookkeeping. On success print `Stored instinct <id> (<domain>, confidence <n>).` and append `**Applied**: <date>` to the proposal block.
|
|
100
|
+
2. **reject** - do not store the unit. Append `**Reviewed: rejected**` to the reflections file.
|
|
101
|
+
3. **defer** - no-op; the unit re-surfaces next run. Append `**Reviewed: deferred**`.
|
|
102
|
+
4. **edit** - let the user adjust `trigger`, `confidence`, or `domain`, then accept the edited unit through the same `add(...)` call. Default `scope: 'project'` (write `global` only when the unit's frontmatter says so); never edit `.design/instincts/instincts.json` directly, and promote to global via the separate gated `/gdd:instinct promote`.
|
|
103
|
+
|
|
87
104
|
## Do Not
|
|
88
105
|
|
|
89
106
|
- Do not apply any proposal without the user explicitly choosing `a` or `e`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gdd-audit
|
|
3
|
-
description: "Run a design audit by spawning design-auditor, design-integration-checker, and (optionally) design-verifier + design-reflector agents, then printing a consolidated
|
|
3
|
+
description: "Run a design audit by spawning design-auditor, design-integration-checker, and (optionally) design-verifier + design-reflector agents, then printing a consolidated 7-pillar score summary. Use when the user wants to score the current design, retroactively verify a completed cycle, or quickly re-check after a fix. Activates for requests involving scoring an existing design, retroactively reviewing quality, or re-checking after a fix."
|
|
4
4
|
argument-hint: "[--retroactive] [--quick] [--no-reflect]"
|
|
5
5
|
tools: Read, Write, Task, Glob, Bash
|
|
6
6
|
---
|
|
@@ -9,12 +9,12 @@ tools: Read, Write, Task, Glob, Bash
|
|
|
9
9
|
|
|
10
10
|
Wraps the existing `design-auditor`, `design-verifier`, and `design-integration-checker` agents - no new auditor logic here. Parses flags, spawns the right combination, prints summary.
|
|
11
11
|
|
|
12
|
-
For the
|
|
12
|
+
For the 7-pillar scoring rubric this skill aggregates, see `../../reference/audit-scoring.md`. For the shared design-quality pillar set that frames the score categories, see `../../reference/shared-preamble.md`.
|
|
13
13
|
|
|
14
14
|
## Modes
|
|
15
15
|
|
|
16
16
|
### Default
|
|
17
|
-
Spawn `design-auditor` (
|
|
17
|
+
Spawn `design-auditor` (7-pillar scoring 1–4) in parallel with `design-integration-checker`. After both finish, read `.design/DESIGN-AUDIT.md` and `.design/DESIGN-INTEGRATION.md` and print a consolidated summary (scores + top 3 findings each).
|
|
18
18
|
|
|
19
19
|
After the auditor and integration checker complete, check if `.design/learnings/` exists and contains at least one `.md` file. If so - and unless `--no-reflect` is passed - spawn `design-reflector` for the current cycle. Append the reflection proposal count to the audit summary: "Reflection: N proposals → review with `/gdd:apply-reflections`".
|
|
20
20
|
|
|
@@ -70,8 +70,8 @@ The excuses an agent reaches for to skip or thin out an audit, and the drift eac
|
|
|
70
70
|
| Thought | Reality |
|
|
71
71
|
|---------|---------|
|
|
72
72
|
| "The audit passed last cycle, I can skip it this cycle." | Per-cycle audit catches drift the prior pass couldn't see; a skipped review is exactly where regressions accumulate unnoticed. |
|
|
73
|
-
| "`--quick` is fine, integration isn't the concern here." | Dropping the integration-checker hides orphaned decisions - wiring breaks even when the
|
|
74
|
-
| "I can eyeball the scores instead of spawning the auditor." | The auditor's rubric scores
|
|
73
|
+
| "`--quick` is fine, integration isn't the concern here." | Dropping the integration-checker hides orphaned decisions - wiring breaks even when the 7-pillar score looks healthy. |
|
|
74
|
+
| "I can eyeball the scores instead of spawning the auditor." | The auditor's rubric scores seven pillars consistently; an eyeballed review drifts toward whatever the agent already believes. |
|
|
75
75
|
| "Reflection proposals are optional polish, skip the reflector." | The reflector turns this cycle's learnings into next-cycle improvements; skipping it lets the same mistakes repeat. |
|
|
76
76
|
| "I'll modify the source while I'm in here fixing findings." | Audit is read-only by contract; editing source mid-audit invalidates the very scores you're producing. |
|
|
77
77
|
| "Retroactive mode is overkill for a finished cycle." | Retroactive verification is the only check on tasks that shipped without per-task verify - skipping it leaves a completed cycle unaudited. |
|
|
@@ -53,6 +53,22 @@ Layout of `.design/learnings/LEARNINGS.md`:
|
|
|
53
53
|
---
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
### Step 3b - Dual-emit atomic instinct units (Phase 51)
|
|
57
|
+
|
|
58
|
+
Alongside the prose `LEARNINGS.md`, emit atomic instinct units for every learning the extractor tags as an `instinct-candidate`. A learning is an `instinct-candidate` when it states a single trigger plus a one-line response - the same shape the reflector emits. Broader narrative learnings stay prose-only.
|
|
59
|
+
|
|
60
|
+
For each `instinct-candidate`, build a unit per `reference/instinct-format.md` (frontmatter: `id`, `trigger`, `confidence` from 0.3 to 0.9, `domain`, `scope`, `project_id`, `source`, `cycles_seen`, `first_seen`, `last_seen`, plus a short body). Set `source: extract-learnings`. Carry the learning's confidence (high / medium / low) into the numeric field (roughly 0.8 / 0.55 / 0.35), capped at 0.9.
|
|
61
|
+
|
|
62
|
+
Write each unit through the store engine `scripts/lib/instinct-store.cjs` rather than by hand:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/instinct-store.cjs" add --scope project
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If the engine exposes a module API only, drive `add(unit, { scope: 'project', baseDir })` from a short `node -e` script. The engine owns de-duplication and `cycles_seen` bookkeeping; do not pre-merge.
|
|
69
|
+
|
|
70
|
+
The prose `LEARNINGS.md` is **retained read-only for one minor version** so existing readers keep working while tooling migrates to the units. Keep writing it; do not drop the prose path in this version.
|
|
71
|
+
|
|
56
72
|
### Step 4 - Reference file proposal (optional)
|
|
57
73
|
|
|
58
74
|
After writing LEARNINGS.md, check each learning entry with `Proposed reference update: yes`.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gdd-instinct
|
|
3
|
+
description: "Inspects and manages atomic instinct learning units - small, scoped, confidence-weighted patterns the pipeline accumulates across cycles. Lists the project and global instinct stores, searches them by keyword, and promotes a vetted project instinct to the global store once it has cleared the cross-project gate. Use when the user wants to see what instincts exist, find an instinct by topic, or promote one to global scope. Activates for requests involving instincts, learned patterns, instinct promotion, instinct search, or the instinct store."
|
|
4
|
+
argument-hint: "[list | query <keyword> | promote <id>] [--scope project|global] [--domain <d>]"
|
|
5
|
+
tools: Read, Bash
|
|
6
|
+
user-invocable: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# /gdd:instinct
|
|
10
|
+
|
|
11
|
+
**Role:** Front end for the atomic instinct store. An instinct is a single learned pattern with a trigger, a confidence between 0.3 and 0.9, a domain, and a scope. This skill lists, searches, and promotes instincts. It never edits stored units by hand and never invents new ones - the reflector and `/gdd:extract-learnings` author them.
|
|
12
|
+
|
|
13
|
+
The store engine ships at `scripts/lib/instinct-store.cjs` (authored elsewhere - this skill only calls it). Unit shape (YAML frontmatter plus a short body) is specified in `reference/instinct-format.md`. The project store lives at `.design/instincts/instincts.json`; the global store at `~/.claude/gdd/global-instincts.json`.
|
|
14
|
+
|
|
15
|
+
Invoke the engine with `node`, the same way other skills call a `scripts/lib` helper:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/instinct-store.cjs" <subcommand> [args]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If the engine exposes only a module API rather than a CLI, drive it from a short `node -e` script:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
node -e "const s=require('${CLAUDE_PLUGIN_ROOT}/scripts/lib/instinct-store.cjs'); console.log(JSON.stringify(s.list({scope:process.env.SCOPE})))"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Invocation Modes
|
|
28
|
+
|
|
29
|
+
| Command | Behavior |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `/gdd:instinct list` | Compact table of stored instincts (default mode). |
|
|
32
|
+
| `/gdd:instinct query "<keyword>"` | Search instincts by keyword; show the top matches. |
|
|
33
|
+
| `/gdd:instinct promote <id>` | Promote one project instinct to the global store (gated). |
|
|
34
|
+
|
|
35
|
+
Flags apply across modes:
|
|
36
|
+
|
|
37
|
+
- `--scope project|global` selects which store to read. Default is `project`.
|
|
38
|
+
- `--domain <d>` filters to one domain (the domain enum is defined in `reference/instinct-format.md`).
|
|
39
|
+
|
|
40
|
+
## list
|
|
41
|
+
|
|
42
|
+
Read the requested store and print a compact table. Call `instinct-store.list({ scope, domain, baseDir })`:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
node -e "const s=require('${CLAUDE_PLUGIN_ROOT}/scripts/lib/instinct-store.cjs'); \
|
|
46
|
+
const rows=s.list({ scope: process.env.SCOPE || 'project', domain: process.env.DOMAIN || undefined }); \
|
|
47
|
+
console.log(JSON.stringify(rows));"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Render one row per instinct. Keep it scannable:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
ID DOMAIN CONF CYCLES TRIGGER
|
|
54
|
+
in-7f3a tokens 0.72 3 palette has no neutral ramp
|
|
55
|
+
in-91bc layout 0.55 2 cards overflow on the 320px breakpoint
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `CONF` is the stored confidence (0.3 to 0.9).
|
|
59
|
+
- `CYCLES` is `cycles_seen`.
|
|
60
|
+
- Truncate `TRIGGER` to keep each line on one row.
|
|
61
|
+
|
|
62
|
+
If the store is empty, print: `No instincts in the <scope> store yet. Run /gdd:reflect or /gdd:extract-learnings to accumulate some.`
|
|
63
|
+
|
|
64
|
+
## query
|
|
65
|
+
|
|
66
|
+
Search by keyword and show the closest matches. Call `instinct-store.query(keyword, { scope, baseDir, limit })`. The engine uses an FTS5 index when one is present and falls back to a plain scan otherwise; either path returns the same row shape.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
node -e "const s=require('${CLAUDE_PLUGIN_ROOT}/scripts/lib/instinct-store.cjs'); \
|
|
70
|
+
const hits=s.query(process.env.KW, { scope: process.env.SCOPE || 'project', limit: 10 }); \
|
|
71
|
+
console.log(JSON.stringify(hits));"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Print the top matches in the same table shape as `list`, ordered by the engine's relevance ranking. If there are no matches, say so plainly and suggest a broader keyword. Quote multi-word keywords so the shell passes one argument.
|
|
75
|
+
|
|
76
|
+
## promote
|
|
77
|
+
|
|
78
|
+
Promote a single project instinct into the global store so it applies across every project. Promotion is **gated**: `instinct-store.promote(id, { baseDir })` only succeeds when the instinct has been seen across at least K cycles (K=2) spanning at least M distinct project ids (M=2). The engine enforces the gate; this skill surfaces the outcome and asks the user to confirm before the write.
|
|
79
|
+
|
|
80
|
+
Confirm first. Prefer `@clack/prompts`, and fall back to `AskUserQuestion` when it is absent (mirror the probe in `/gdd:new-skill`):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
node -e "try { require.resolve('@clack/prompts'); console.log('clack'); } catch { console.log('fallback'); }"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- `clack`: drive `clack.confirm({ message: 'Promote <id> to the global store?' })` from a short Node script.
|
|
87
|
+
- `fallback`: ask the same yes or no question with `AskUserQuestion`.
|
|
88
|
+
|
|
89
|
+
On a confirmed yes, run the promotion:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
node -e "const s=require('${CLAUDE_PLUGIN_ROOT}/scripts/lib/instinct-store.cjs'); \
|
|
93
|
+
console.log(JSON.stringify(s.promote(process.env.ID, {})));"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Branch on the engine result:
|
|
97
|
+
|
|
98
|
+
- Promotion succeeded: print `Promoted <id> to the global store.` and show the new global row.
|
|
99
|
+
- Gate not met: the engine reports how far the instinct is from the K=2 / M=2 bar. Print that plainly, for example `<id> needs 2 cycles across 2 projects; seen 1 cycle in 1 project so far. Not promoted.` Do not retry and do not force the write.
|
|
100
|
+
- Unknown id: print `No instinct <id> in the project store.` and suggest `/gdd:instinct list`.
|
|
101
|
+
|
|
102
|
+
If the user answers no at the confirm step, print `Promotion cancelled.` and exit without writing.
|
|
103
|
+
|
|
104
|
+
## Do Not
|
|
105
|
+
|
|
106
|
+
- Do not edit `.design/instincts/instincts.json` or the global store by hand. All writes go through `scripts/lib/instinct-store.cjs`.
|
|
107
|
+
- Do not author new instincts here. The reflector and `/gdd:extract-learnings` emit units; this skill reads and promotes them.
|
|
108
|
+
- Do not bypass the promotion gate. If the K=2 / M=2 bar is not met, report it and stop.
|
|
109
|
+
- Do not modify `reference/instinct-format.md` or the store engine.
|
|
110
|
+
|
|
111
|
+
## INSTINCT COMPLETE
|
|
@@ -49,7 +49,7 @@ Run preview / storybook / chromatic probes at stage entry, then issue ONE batche
|
|
|
49
49
|
|
|
50
50
|
Initialize the fix-loop iteration counter to 0. Each full checker is preceded by a cheap Haiku gate that may return `{spawn: false}` to short-circuit (lazy-gate pattern from Plan 10.1-04 / D-21); skipped agents append `lazy_skipped: true` to `.design/telemetry/costs.jsonl`.
|
|
51
51
|
|
|
52
|
-
**1a. design-auditor** (retrospective
|
|
52
|
+
**1a. design-auditor** (retrospective 7-pillar audit) -> `.design/DESIGN-AUDIT.md`. Wait for `## AUDIT COMPLETE`, then `mcp__gdd_state__update_progress` `task_progress: "1/3"`.
|
|
53
53
|
|
|
54
54
|
**1b-gate -> 1b. design-verifier** (5-phase verification, reads auditor output) -> `.design/DESIGN-VERIFICATION.md`. Wait for `## VERIFICATION COMPLETE`, then `task_progress: "2/3"`.
|
|
55
55
|
|
|
@@ -204,7 +204,7 @@ Three agents run in sequence. Each waits for its completion marker before the ne
|
|
|
204
204
|
|
|
205
205
|
**Note on lazy gates (Plan 10.1-04 / D-21):** Each full checker is preceded by a cheap Haiku gate that reads the diff and may return `{spawn: false}` to short-circuit. When gated out, `lazy_skipped: true` is appended to `.design/telemetry/costs.jsonl`. Gates: `design-verifier-gate` (before 1b), `design-integration-checker-gate` (before 1c). `design-context-checker-gate` is wired into `skills/discover/SKILL.md` Step 1.75.
|
|
206
206
|
|
|
207
|
-
### 1a. Run design-auditor first (retrospective
|
|
207
|
+
### 1a. Run design-auditor first (retrospective 7-pillar audit)
|
|
208
208
|
|
|
209
209
|
```
|
|
210
210
|
Task("design-auditor", """
|
|
@@ -216,7 +216,7 @@ Task("design-auditor", """
|
|
|
216
216
|
@reference/audit-scoring.md
|
|
217
217
|
</required_reading>
|
|
218
218
|
|
|
219
|
-
You are the design-auditor agent. Run the
|
|
219
|
+
You are the design-auditor agent. Run the 7-pillar retrospective audit (copy, visual hierarchy,
|
|
220
220
|
color, typography, layout/spacing, experience design) against the completed design work.
|
|
221
221
|
|
|
222
222
|
Score each pillar 1-4. Write your findings to .design/DESIGN-AUDIT.md.
|
|
@@ -273,7 +273,7 @@ Task("design-verifier", """
|
|
|
273
273
|
|
|
274
274
|
You are the design-verifier agent. Run the 5-phase verification against completed design work.
|
|
275
275
|
|
|
276
|
-
DESIGN-AUDIT.md (above) contains a retrospective
|
|
276
|
+
DESIGN-AUDIT.md (above) contains a retrospective 7-pillar qualitative audit from design-auditor.
|
|
277
277
|
Read it as supplementary signal — incorporate the priority fix list into your Phase 5 gap analysis
|
|
278
278
|
where relevant. The auditor's 1-4 scores complement your 0-10 category scores; they do not
|
|
279
279
|
replace your Phase 1 category scoring.
|
|
@@ -463,7 +463,7 @@ Task("design-verifier", """
|
|
|
463
463
|
|
|
464
464
|
You are the design-verifier agent. This is a re-verification run after inline fixes.
|
|
465
465
|
|
|
466
|
-
DESIGN-AUDIT.md contains the retrospective
|
|
466
|
+
DESIGN-AUDIT.md contains the retrospective 7-pillar audit from design-auditor (read as supplementary context).
|
|
467
467
|
|
|
468
468
|
Context:
|
|
469
469
|
auto_mode: <true|false>
|
|
@@ -496,7 +496,7 @@ Status: PASS | FAIL | ACCEPTED-WITH-GAPS
|
|
|
496
496
|
Gaps: X blockers, Y majors, Z minors, W cosmetics
|
|
497
497
|
|
|
498
498
|
Agents run:
|
|
499
|
-
design-auditor -> .design/DESIGN-AUDIT.md (
|
|
499
|
+
design-auditor -> .design/DESIGN-AUDIT.md (7-pillar qualitative)
|
|
500
500
|
design-verifier-gate -> JSON gate decision (may skip design-verifier)
|
|
501
501
|
design-verifier -> .design/DESIGN-VERIFICATION.md (7-category + heuristics + UAT)
|
|
502
502
|
design-integration-checker-gate -> JSON gate decision (may skip design-integration-checker)
|
|
@@ -402,6 +402,96 @@ function buildAdrBlock(matched) {
|
|
|
402
402
|
return lines.join('\n');
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Phase 51 — surface the project instinct store's top matches for the opened
|
|
407
|
+
* file. Instinct units are atomic, confidence-weighted design instincts learned
|
|
408
|
+
* across cycles (schema: reference/instinct-format.md), persisted + ranked by
|
|
409
|
+
* scripts/lib/instinct-store.cjs. The store is a SIBLING module — we reference
|
|
410
|
+
* it by name and never reimplement its query/decay logic.
|
|
411
|
+
*
|
|
412
|
+
* Two seams keep this testable + resilient:
|
|
413
|
+
* - `instinctTokens()` derives the query keyword(s) from the opened file's
|
|
414
|
+
* basename + relPath (mirrors the matchTokens derivation used for glossary
|
|
415
|
+
* /ADR matching, so an opened `color-tokens.md` queries on `color`+`tokens`).
|
|
416
|
+
* - `buildInstinctsBlock()` is a PURE renderer over already-fetched units, so
|
|
417
|
+
* the populated-path render is unit-testable without the store on disk.
|
|
418
|
+
*
|
|
419
|
+
* The store query itself (in main()) is wrapped in try/catch and is fully
|
|
420
|
+
* non-fatal: if the store module is absent (sibling not yet installed) or its
|
|
421
|
+
* data file is missing/corrupt, the block is silently skipped and the hook
|
|
422
|
+
* still returns { continue: true }.
|
|
423
|
+
*/
|
|
424
|
+
function instinctTokens(basename, relPath) {
|
|
425
|
+
const stem = basename.replace(/\.md$/i, '');
|
|
426
|
+
return Array.from(new Set([
|
|
427
|
+
stem,
|
|
428
|
+
...stem.split(/[-_./\\]/),
|
|
429
|
+
...String(relPath || '').split(/[-_./\\]/),
|
|
430
|
+
].filter((t) => t && t.length > 2)));
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Pure renderer: format up to the top-3 instinct units as a compact block.
|
|
435
|
+
* Each line carries the trigger, confidence (2dp), and domain. Returns null when
|
|
436
|
+
* there are no units so main() can omit the heading entirely.
|
|
437
|
+
*
|
|
438
|
+
* Defensive: tolerates missing fields (trigger/confidence/domain) and non-array
|
|
439
|
+
* input so a malformed store payload can never throw on the Read hot path.
|
|
440
|
+
*
|
|
441
|
+
* @param {Array<{id?: string, trigger?: string, confidence?: number, domain?: string}>} units
|
|
442
|
+
* @returns {string | null}
|
|
443
|
+
*/
|
|
444
|
+
function buildInstinctsBlock(units) {
|
|
445
|
+
if (!Array.isArray(units) || units.length === 0) return null;
|
|
446
|
+
const top = units.slice(0, 3);
|
|
447
|
+
const lines = [];
|
|
448
|
+
lines.push('');
|
|
449
|
+
lines.push('### Relevant instincts');
|
|
450
|
+
for (const u of top) {
|
|
451
|
+
if (!u || typeof u !== 'object') continue;
|
|
452
|
+
const trigger = (u.trigger == null ? '' : String(u.trigger)).trim() || '(no trigger)';
|
|
453
|
+
const conf = typeof u.confidence === 'number' && Number.isFinite(u.confidence)
|
|
454
|
+
? u.confidence.toFixed(2)
|
|
455
|
+
: '?';
|
|
456
|
+
const domain = (u.domain == null ? '' : String(u.domain)).trim() || 'unknown';
|
|
457
|
+
lines.push(`> - ${trigger} (confidence ${conf}, ${domain})`);
|
|
458
|
+
}
|
|
459
|
+
// If every unit was malformed (no valid line emitted), drop the block.
|
|
460
|
+
if (lines.length <= 2) return null;
|
|
461
|
+
lines.push('');
|
|
462
|
+
return lines.join('\n');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Non-fatal glue: query the project instinct store for the opened file's tokens
|
|
467
|
+
* and render the block. Any failure (module absent, query throws, bad data)
|
|
468
|
+
* yields null so the caller simply omits the section. NEVER throws.
|
|
469
|
+
*
|
|
470
|
+
* @param {string} cwd — project root (passed to the store as baseDir)
|
|
471
|
+
* @param {string} basename
|
|
472
|
+
* @param {string} relPath
|
|
473
|
+
* @returns {string | null}
|
|
474
|
+
*/
|
|
475
|
+
function queryInstinctsBlock(cwd, basename, relPath) {
|
|
476
|
+
try {
|
|
477
|
+
// Sibling module — referenced by name, resolved relative to this hook.
|
|
478
|
+
// Absent in installs that predate Phase 51's instinct store.
|
|
479
|
+
// eslint-disable-next-line node/no-missing-require, global-require
|
|
480
|
+
const store = require(path.join(__dirname, '..', 'scripts', 'lib', 'instinct-store.cjs'));
|
|
481
|
+
if (!store || typeof store.query !== 'function') return null;
|
|
482
|
+
const tokens = instinctTokens(basename, relPath);
|
|
483
|
+
if (tokens.length === 0) return null;
|
|
484
|
+
// instinct-store.query() takes a STRING keyword (it splits on whitespace
|
|
485
|
+
// into terms) — pass the tokens space-joined, not the raw array.
|
|
486
|
+
const keyword = tokens.join(' ');
|
|
487
|
+
const units = store.query(keyword, { scope: 'project', baseDir: cwd, limit: 3 });
|
|
488
|
+
return buildInstinctsBlock(units);
|
|
489
|
+
} catch {
|
|
490
|
+
// Store missing or query failed — surface no instinct block, never crash.
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
405
495
|
function buildRecallBlock(matches, basename, backendLabel) {
|
|
406
496
|
if (!matches.length) return null;
|
|
407
497
|
const uniq = [];
|
|
@@ -526,21 +616,40 @@ async function main() {
|
|
|
526
616
|
adrBlock = buildAdrBlock(matchedAdrs);
|
|
527
617
|
} catch { /* defensive: never crash on ADR issues */ }
|
|
528
618
|
|
|
529
|
-
|
|
619
|
+
// Phase 51: surface the project instinct store's top-3 matches for the
|
|
620
|
+
// opened file. Fully non-fatal — queryInstinctsBlock swallows a missing
|
|
621
|
+
// store / bad data and returns null, so this can never break a Read.
|
|
622
|
+
const instinctsBlock = queryInstinctsBlock(cwd, basename, relPath);
|
|
623
|
+
|
|
624
|
+
if (!block && !protoBlock && !glossaryBlock && !adrBlock && !instinctsBlock) {
|
|
530
625
|
try { require('./_hook-emit.js').emitHookFired('gdd-decision-injector', 'no-hits', { backend: backendLabel }); } catch { /* swallow */ }
|
|
531
626
|
process.stdout.write(JSON.stringify({ continue: true }));
|
|
532
627
|
return;
|
|
533
628
|
}
|
|
534
629
|
|
|
535
|
-
const additionalContext = [block, protoBlock, glossaryBlock, adrBlock].filter(Boolean).join('\n');
|
|
630
|
+
const additionalContext = [block, protoBlock, glossaryBlock, adrBlock, instinctsBlock].filter(Boolean).join('\n');
|
|
536
631
|
|
|
537
|
-
try { require('./_hook-emit.js').emitHookFired('gdd-decision-injector', 'inject', { backend: backendLabel, hit_count: hits.length, prototyping: !!protoBlock, glossary: !!glossaryBlock, adr: !!adrBlock }); } catch { /* swallow */ }
|
|
632
|
+
try { require('./_hook-emit.js').emitHookFired('gdd-decision-injector', 'inject', { backend: backendLabel, hit_count: hits.length, prototyping: !!protoBlock, glossary: !!glossaryBlock, adr: !!adrBlock, instincts: !!instinctsBlock }); } catch { /* swallow */ }
|
|
538
633
|
process.stdout.write(JSON.stringify({
|
|
539
634
|
continue: true,
|
|
540
635
|
hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext },
|
|
541
636
|
}));
|
|
542
637
|
}
|
|
543
638
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
639
|
+
// Auto-run when invoked directly (the hooks.json registration runs this hook
|
|
640
|
+
// as `node hooks/gdd-decision-injector.js`, where require.main === module).
|
|
641
|
+
// Guarding the auto-run lets tests require() the module in-process to unit-test
|
|
642
|
+
// the pure helpers without triggering a stdin read.
|
|
643
|
+
if (require.main === module) {
|
|
644
|
+
main().catch(() => {
|
|
645
|
+
process.stdout.write(JSON.stringify({ continue: true }));
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// Exported for tests — pure helpers only; main() owns the I/O + contract.
|
|
650
|
+
module.exports = {
|
|
651
|
+
buildInstinctsBlock,
|
|
652
|
+
instinctTokens,
|
|
653
|
+
queryInstinctsBlock,
|
|
654
|
+
main,
|
|
655
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hegemonart/get-design-done",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.51.0",
|
|
4
4
|
"description": "A design-quality pipeline for AI coding agents: brief, plan, implement, and verify UI work against your design system.",
|
|
5
5
|
"author": "Hegemon",
|
|
6
6
|
"homepage": "https://github.com/hegemonart/get-design-done",
|