@hegemonart/get-design-done 1.50.1 → 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 +1 -1
- package/CHANGELOG.md +46 -0
- package/README.md +2 -0
- package/SKILL.md +2 -1
- 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/extract-learnings/SKILL.md +16 -0
- package/dist/claude-code/.claude/skills/instinct/SKILL.md +111 -0
- package/hooks/gdd-decision-injector.js +115 -6
- package/package.json +1 -1
- package/reference/instinct-format.md +120 -0
- package/reference/registry.json +7 -0
- package/reference/schemas/events.schema.json +1 -1
- package/reference/schemas/instinct.schema.json +91 -0
- package/reference/skill-graph.md +2 -1
- package/scripts/lib/instinct-store.cjs +677 -0
- package/scripts/lib/manifest/skills.json +8 -0
- package/skills/apply-reflections/SKILL.md +17 -0
- package/skills/extract-learnings/SKILL.md +16 -0
- package/skills/instinct/SKILL.md +111 -0
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "get-design-done",
|
|
3
3
|
"short_name": "gdd",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.51.0",
|
|
5
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",
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,52 @@ 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
|
+
|
|
7
53
|
## [1.50.1] - 2026-06-03
|
|
8
54
|
|
|
9
55
|
### Fixed
|
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. |
|
|
@@ -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`.
|
|
@@ -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
|
|
@@ -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",
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: instinct-format
|
|
3
|
+
type: meta-rules
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
phase: 51
|
|
6
|
+
tags: [instinct, learning, confidence, beta-prior, promotion-gate, ttl-decay]
|
|
7
|
+
last_updated: 2026-06-03
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Instinct Unit Format
|
|
11
|
+
|
|
12
|
+
An instinct is an atomic, confidence-weighted lesson the pipeline learns across design
|
|
13
|
+
cycles. Where an ADR records a deliberate, hard-to-reverse decision (see `./adr-format.md`)
|
|
14
|
+
and `CONTEXT.md` records agreed vocabulary (see `./context-md-format.md`), an instinct
|
|
15
|
+
records a softer signal: a recurring "when X, prefer Y" reflex that earns trust by being
|
|
16
|
+
seen again and again. Each unit is one trigger sentence plus a short body, stored as a YAML
|
|
17
|
+
document and validated by `./schemas/instinct.schema.json`. The store
|
|
18
|
+
(`scripts/lib/instinct-store.cjs`) persists, queries, promotes, and decays them.
|
|
19
|
+
|
|
20
|
+
Instincts are always advisory, never directive. A fresh instinct carries low confidence and
|
|
21
|
+
is offered as a suggestion; only repeated cross-project observation raises that confidence,
|
|
22
|
+
and even then it is capped well below certainty.
|
|
23
|
+
|
|
24
|
+
## Unit shape
|
|
25
|
+
|
|
26
|
+
A unit is a YAML frontmatter block followed by a 1 to 3 paragraph body. The body explains
|
|
27
|
+
the reflex in plain language: what situation fires it, what to reach for, and why.
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
---
|
|
31
|
+
id: prefer-token-over-hex # kebab-case stable identifier
|
|
32
|
+
trigger: When a raw color literal appears in a component, reach for a design token first.
|
|
33
|
+
confidence: 0.5 # float in [0.3, 0.9]
|
|
34
|
+
domain: build # intake|explore|decide|build|verify|operate|utility
|
|
35
|
+
scope: project # project|global
|
|
36
|
+
project_id: abcd1234 # sha8 of the normalized git origin (project scope)
|
|
37
|
+
source: reflection # reflection|extract-learnings|user
|
|
38
|
+
cycles_seen: 1 # distinct cycles that surfaced this instinct
|
|
39
|
+
project_ids: [abcd1234] # distinct origins that surfaced it (promotion gate)
|
|
40
|
+
first_seen: 2026-06-01 # ISO date the unit was recorded
|
|
41
|
+
last_seen: 2026-06-01 # ISO date it was last surfaced (resets decay)
|
|
42
|
+
---
|
|
43
|
+
Hardcoded hex values drift away from the system palette over time. Routing the value
|
|
44
|
+
through a token keeps one source of truth and lets a theme change land everywhere at once.
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Field reference
|
|
48
|
+
|
|
49
|
+
- **id** (required). Kebab-case, lowercase letters and digits with single hyphens, 3 to 80
|
|
50
|
+
characters. The id is stable: touching or promoting a unit never changes it.
|
|
51
|
+
- **trigger** (required). One sentence naming the situation that fires the instinct. Keep it
|
|
52
|
+
concrete enough that a reader knows when it applies.
|
|
53
|
+
- **confidence** (required). A float between 0.3 and 0.9. The floor of 0.3 says a brand-new
|
|
54
|
+
instinct is a hint, not a rule. The ceiling of 0.9 says no instinct is ever certain.
|
|
55
|
+
- **domain** (required). One of `intake`, `explore`, `decide`, `build`, `verify`, `operate`,
|
|
56
|
+
`utility`. These map to the Phase 50 lifecycle stages so an instinct surfaces at the right
|
|
57
|
+
moment in a cycle.
|
|
58
|
+
- **scope** (required). `project` for a lesson learned in one repository, `global` for one
|
|
59
|
+
promoted after it clears the cross-project gate below.
|
|
60
|
+
- **project_id** (required for project scope). The 8-character hex sha of the normalized git
|
|
61
|
+
origin, produced by `deriveProjectId`. A global unit may omit it, since a promoted instinct
|
|
62
|
+
is no longer tied to a single origin.
|
|
63
|
+
- **source** (required). Which producer minted the unit: a `reflection` pass, the
|
|
64
|
+
`extract-learnings` step, or a direct `user` assertion.
|
|
65
|
+
- **cycles_seen** (optional, defaults to 1). How many distinct cycles have surfaced the unit.
|
|
66
|
+
- **project_ids** (optional). The set of distinct origins that surfaced it. Its size feeds the
|
|
67
|
+
promotion gate.
|
|
68
|
+
- **first_seen** / **last_seen** (optional, stamped on write). ISO dates for recording and last
|
|
69
|
+
surfacing. `last_seen` resets the decay window.
|
|
70
|
+
|
|
71
|
+
## The Beta(2,8) prior
|
|
72
|
+
|
|
73
|
+
When an instinct is promoted to the global store it is seeded with a Beta(2,8) posterior, the
|
|
74
|
+
same conservative prior the Phase 38 `design_arms` store uses. Its posterior mean is 0.2, so a
|
|
75
|
+
promoted pattern still has to earn standing from real outcomes rather than starting trusted.
|
|
76
|
+
The store exposes this as `INSTINCT_PRIOR = {alpha: 2, beta: 8}`. Successful outcomes add to
|
|
77
|
+
`alpha`, disappointing ones add to `beta`, and the mean moves accordingly.
|
|
78
|
+
|
|
79
|
+
## Promotion gate (K=2 cycles across M=2 projects)
|
|
80
|
+
|
|
81
|
+
A project instinct may move to the global store only when both halves of the gate hold:
|
|
82
|
+
|
|
83
|
+
1. **K = 2 cycles.** `cycles_seen` is at least 2, so the lesson repeated rather than firing once.
|
|
84
|
+
2. **M = 2 projects.** The unit appears in at least 2 distinct `project_ids`, so the lesson
|
|
85
|
+
generalized beyond the repository that first taught it.
|
|
86
|
+
|
|
87
|
+
`promote(id)` throws a clear error when either half is unmet, so a one-off observation in a
|
|
88
|
+
single project can never leak into global advice. On a passing gate the unit is re-scoped to
|
|
89
|
+
`global`, the single-origin `project_id` is dropped, the Beta(2,8) prior is applied, and the
|
|
90
|
+
unit is removed from the project store. `touch(id)` is how a unit accumulates toward the gate:
|
|
91
|
+
each call bumps `last_seen` and `cycles_seen` and adds the current origin to `project_ids`.
|
|
92
|
+
|
|
93
|
+
## TTL decay
|
|
94
|
+
|
|
95
|
+
Instincts that stop showing up should fade rather than linger as stale advice. `decay()` walks
|
|
96
|
+
a scope and, for any unit not surfaced within the decay window of 6 cycles, multiplies its
|
|
97
|
+
confidence by 0.9. Once a unit's confidence falls below 0.2 it is archived: the store writes it
|
|
98
|
+
to `<root>/instincts/archive/<id>.json` with an `archived_at` stamp and removes it from the live
|
|
99
|
+
set. Archiving is reversible by hand, so the audit trail survives. Calling `touch(id)` resets the
|
|
100
|
+
window, so an instinct that keeps proving useful never decays.
|
|
101
|
+
|
|
102
|
+
## Storage and recall
|
|
103
|
+
|
|
104
|
+
Project units live at `<root>/instincts/instincts.json`, resolved through the worktree-aware
|
|
105
|
+
root so writes land in the main checkout rather than a throwaway worktree. Global units live at
|
|
106
|
+
`~/.claude/gdd/global-instincts.json`. Both files are written atomically (a temp file plus a
|
|
107
|
+
rename), and JSON is always the source of truth.
|
|
108
|
+
|
|
109
|
+
`query(keyword)` ranks units by how well the keyword matches their trigger, body, and domain,
|
|
110
|
+
returning the best few. When `better-sqlite3` is present with its FTS5 extension the query runs
|
|
111
|
+
over a small full-text index for speed; otherwise an in-memory scan answers the same query with
|
|
112
|
+
the same shape. `better-sqlite3` stays a runtime probe and is never a hard dependency, so recall
|
|
113
|
+
degrades gracefully wherever the native module is absent. `backendName()` reports which path is
|
|
114
|
+
active.
|
|
115
|
+
|
|
116
|
+
## Cross-references
|
|
117
|
+
|
|
118
|
+
- Hard-to-reverse decisions belong in an ADR, not an instinct. See `./adr-format.md`.
|
|
119
|
+
- Agreed domain vocabulary belongs in `CONTEXT.md`. See `./context-md-format.md`.
|
|
120
|
+
- The frontmatter schema is `./schemas/instinct.schema.json`, validated under Ajv.
|
package/reference/registry.json
CHANGED
|
@@ -1149,6 +1149,13 @@
|
|
|
1149
1149
|
"type": "meta-rules",
|
|
1150
1150
|
"phase": 50,
|
|
1151
1151
|
"description": "Phase 50 auto-generated skill composition graph (mermaid): skills grouped by lifecycle stage with composes_with and next_skills edges; regenerated by scripts/generate-skill-graph.cjs and drift-gated in CI."
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"name": "instinct-format",
|
|
1155
|
+
"path": "reference/instinct-format.md",
|
|
1156
|
+
"type": "meta-rules",
|
|
1157
|
+
"phase": 51,
|
|
1158
|
+
"description": "Phase 51 instinct unit format: YAML frontmatter (id, trigger, confidence 0.3-0.9, domain, scope, project_id, source, cycles_seen, first/last_seen) + body; promotion gate K=2/M=2; Beta(2,8) prior; TTL decay. Stored via scripts/lib/instinct-store.cjs."
|
|
1152
1159
|
}
|
|
1153
1160
|
]
|
|
1154
1161
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": {
|
|
11
11
|
"type": "string",
|
|
12
12
|
"minLength": 1,
|
|
13
|
-
"description": "Free-form event type identifier. Pre-registered seeds: state.mutation, state.transition, stage.entered, stage.exited, hook.fired, error, capability_gap, kfm-candidate, router_pick, verify_outcome, rollout_started, rollout_advanced, rollout_stuck, budget_forecast, project_cap_warning, project_cap_halt, live_session_start, live_pick, live_generate, live_accept, live_discard, live_session_end."
|
|
13
|
+
"description": "Free-form event type identifier. Pre-registered seeds: state.mutation, state.transition, stage.entered, stage.exited, hook.fired, error, capability_gap, kfm-candidate, router_pick, verify_outcome, rollout_started, rollout_advanced, rollout_stuck, budget_forecast, project_cap_warning, project_cap_halt, live_session_start, live_pick, live_generate, live_accept, live_discard, live_session_end, instinct_emitted, instinct_promoted, instinct_decayed."
|
|
14
14
|
},
|
|
15
15
|
"timestamp": {
|
|
16
16
|
"type": "string",
|