@design-ai/cli 4.58.0 → 4.60.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "design-ai",
3
- "version": "4.58.0",
3
+ "version": "4.60.0",
4
4
  "description": "Senior product designer for any AI coding agent. 20 skills, 17 commands, 4 review agents covering UI/UX, website improvement, design systems, motion, illustration, print, video, game UI, conversational, and spatial design. Korean market depth.",
5
5
  "author": {
6
6
  "name": "Sungjin Park",
package/CHANGELOG.md CHANGED
@@ -2,6 +2,59 @@
2
2
 
3
3
  User-facing release notes for design-ai. Versions follow semver.
4
4
 
5
+ ## v4.60.0 — Agent SDK types and local-write namespace (2026-07)
6
+
7
+ Extends the Agent SDK (`@design-ai/cli/sdk`) two ways, both additive and backward-compatible. First, hand-written TypeScript declarations now ship with the package, so TypeScript and editors resolve `@design-ai/cli/sdk` with full types — no `@types` install and no build step. Second, an opt-in `learn.*` namespace adds the SDK's first local-write verbs, keeping the eight Phase A verbs read-only and unchanged.
8
+
9
+ ### Added
10
+ - `cli/sdk/index.d.ts` — hand-written type declarations for all eight read-only verbs (precise signatures and return interfaces, including `search` ranked/plain overloads, the `RouteConfidence` union, and optional `learningContext`/`recall`/`relatedKnowledge` fields) plus the `learn` namespace. Wired through an `exports` `types` condition, so `moduleResolution: node16`/`nodenext`/`bundler` consumers get types automatically. A `node --test` guard (`cli/sdk/types.test.mjs`) keeps the declarations in exact sync with the runtime exports; the declarations are verified to compile under `tsc --strict`.
11
+ - `learn` — a frozen namespace grouping the SDK's only writing verbs (Phase B): `learn.remember(text, { category })`, `learn.feedback(text, { outcome, category })`, and `learn.captureFromCheck(artifact, { routeId })`. Each writes only the local learning profile (`DESIGN_AI_LEARNING_FILE`), never the network, mirroring the CLI's `learn remember` / `learn feedback` / `check --learn` write paths. There is no `filePath` or timestamp option — consumers target a profile via the env var, exactly like the CLI.
12
+
13
+ ### Changed
14
+ - The eight Phase A verbs (`route`, `prompt`, `pack`, `search`, `recall`, `check`, `routes`, `version`) remain read-only and unchanged. `check` in particular stays read-only: capture lives in `learn.captureFromCheck`, never as a `check` option. The SDK contract test (`cli/sdk/index.test.mjs`) now pins both the eight read-only function verbs and the frozen `learn` namespace with its three verbs and their return-shape keys.
15
+ - `tools/audit/package-smoke.py` now also exercises `learn.remember` from the installed tarball against a temp `DESIGN_AI_LEARNING_FILE`, asserting the write.
16
+
17
+ ### Verified
18
+ - All 8 audits passed.
19
+ - `npm run release:check`.
20
+ - `npm run release:metadata`.
21
+ - `git diff --check`.
22
+ - Main-branch GitHub Actions (`Design-AI audit`, `Deploy doc site`) passed for the constituent commits.
23
+
24
+ ### Versions
25
+ - `package.json` + `.claude-plugin/plugin.json`: 4.59.0 → 4.60.0.
26
+ - `vscode-extension/package.json`: remains 0.4.1.
27
+
28
+ ### What this enables
29
+ - TypeScript consumers get first-class types for the whole SDK with zero toolchain cost on either side, and agents can now record design preferences, feedback, and check-derived learnings through a single explicit, opt-in write namespace — while every read-only verb keeps its no-write guarantee.
30
+
31
+ ## v4.59.0 — Agent SDK Phase A (2026-07)
32
+
33
+ Adds a curated, semver-stable programmatic surface — `@design-ai/cli/sdk` — so an external Node.js program can call design-ai's deterministic design verbs as importable functions, without shelling out to the CLI or spawning the MCP server. The SDK is a thin adapter over the same `cli/lib` functions the CLI and MCP already call, so no design behavior changes. Phase A is read-only: no file writes, no network, no runtime dependencies. All additions are additive and backward-compatible.
34
+
35
+ ### Added
36
+ - `@design-ai/cli/sdk` — eight read-only adapter verbs with their own stable signatures: `route(brief, opts)`, `prompt(brief, opts)`, `pack(brief, opts)`, `search(query, opts)`, `recall(query, opts)`, `check(artifact, opts)`, `routes()`, and `version()`. Each validates its inputs, resolves the package root the same way the CLI does, and returns the same JSON-serializable shape the CLI's `--json` mode emits. `check` operates on artifact content (not a path), so it reads and writes nothing.
37
+ - `package.json` `exports` map exposing `./sdk` (and `./package.json`) as the only public import paths; `cli/lib/*` stays internal and unstable, refactorable behind the adapter seam.
38
+ - `docs/SDK.md` — the public SDK reference (surface, return shapes, semver stability contract) — plus a "Node.js / Agent SDK" row in the README install tables and an Agent SDK mkdocs nav section.
39
+
40
+ ### Changed
41
+ - `npm test` now also runs `cli/sdk/*.test.mjs` (61 new SDK tests, 540 total), including a contract test (`cli/sdk/index.test.mjs`) that pins the eight exported names and their return-shape keys — the semver anchor — and asserts Phase A writes no `learningUsage` sidecar.
42
+ - `tools/audit/package-smoke.py` now imports `@design-ai/cli/sdk` from the installed tarball and exercises the eight verbs, asserting determinism and the read-only guarantee.
43
+
44
+ ### Verified
45
+ - All 8 audits passed.
46
+ - `npm run release:check`.
47
+ - `npm run release:metadata`.
48
+ - `git diff --check`.
49
+ - Main-branch GitHub Actions (`Design-AI audit`, `Deploy doc site`) passed for the constituent commits.
50
+
51
+ ### Versions
52
+ - `package.json` + `.claude-plugin/plugin.json`: 4.58.0 → 4.59.0.
53
+ - `vscode-extension/package.json`: remains 0.4.1.
54
+
55
+ ### What this enables
56
+ - Agent runtimes, build scripts, and custom tools can consume design-ai's routing, prompt/pack generation, ranked search, recall, and artifact checks as plain functions — deterministic, in-process, zero-dependency — with a semver-stable contract independent of the internal `cli/lib` shapes.
57
+
5
58
  ## v4.58.0 — Retrieval Across Surfaces and Corpus Depth (2026-07)
6
59
 
7
60
  Completes the retrieval integration started in v4.57.0 by bringing it to the last untouched surface (`route --explain`), refines recall quality so injected knowledge is real design guidance rather than index files, and closes the remaining dogfood-named corpus gaps. All additions are additive and backward-compatible; default output is unchanged unless a flag is passed.
package/README.ko.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  > **모델이 아니에요. 파인튜닝도 아니에요.** 디자인 전문 지식을 구조화한 코퍼스 + 에이전트가 바로 실행할 수 있는 지시문이에요. 범용 LLM을 이번 세션에서만큼은 시니어 디자이너로 바꿔주는 셈이에요.
14
14
 
15
- > **배포 상태, 2026-07-03 확인:** 로컬 `npm run release:check`는 통과했고, GitHub Pages 문서는 live 상태이며, GitHub Release `v4.57.0`과 npm `@design-ai/cli@4.57.0`(`latest`) publish가 provenance와 함께 확인됐어요. Homebrew formula는 `v4.57.0`에 pinning되어 있고, VS Code Marketplace에는 `sungjin.design-ai-vscode@0.4.1`이 공개되어 있어요. v4.57.0 post-publish live registry smoke는 stale 어서션에 걸렸고(`main`에서 수정됨), 패키지는 pre-publish packed-tarball smoke로 검증됐어요. 자세한 내용은 [`docs/external-status.md`](docs/external-status.md)를 확인하세요.
15
+ > **배포 상태, 2026-07-04 확인:** 로컬 `npm run release:check`는 통과했고, GitHub Pages 문서는 live 상태이며, GitHub Release `v4.59.0`과 npm `@design-ai/cli@4.59.0`(`latest`) publish가 provenance와 함께 확인됐어요. 이번 릴리스는 읽기 전용 Agent SDK 표면(`@design-ai/cli/sdk`, 8개 어댑터 verb)을 추가했고 additive라 CLI 출력은 그대로예요. live `npm run registry:smoke`가 published `@design-ai/cli@4.59.0`에 대해 깨끗이 통과했어요(retrieval 표면과 route enrichment 포함). Homebrew formula는 `v4.59.0`에 pinning되어 있고, VS Code Marketplace에는 `sungjin.design-ai-vscode@0.4.1`이 공개되어 있어요. 자세한 내용은 [`docs/external-status.md`](docs/external-status.md)를 확인하세요.
16
16
 
17
17
  ## 한눈에 보는 커버리지
18
18
 
@@ -88,6 +88,7 @@ CLI 명령어: `design-ai install [--json]`, `update [--dry-run] [--json]`, `uni
88
88
  | **Cursor** | 이 폴더를 열고 `AGENTS.md`를 `.cursorrules`로 심볼릭 링크하거나 복사해요. [워크스루](docs/integrations/cursor-walkthrough.md). |
89
89
  | **Aider** | `AGENTS.md`를 시스템 프롬프트로 전달해요. [워크스루](docs/integrations/aider-walkthrough.md). |
90
90
  | **Anthropic / OpenAI SDK** | 관련 스킬 `PLAYBOOK.md` 파일을 프롬프트에 포함시켜요. [워크스루](docs/integrations/sdk-walkthrough.md). |
91
+ | **Node.js / Agent SDK** | `import { route, prompt, pack, search, recall, check, routes, version } from "@design-ai/cli/sdk"` — CLI 셸 실행이나 MCP 서버 없이 design-ai의 결정적 기능을 함수로 바로 호출해요. 읽기 전용(Phase A). [SDK 레퍼런스](docs/SDK.md). |
91
92
  | **일반 프롬프트** | 어떤 `skills/*/PLAYBOOK.md` 본문이든 붙여넣으세요 — 각각 자기 완결적이에요. |
92
93
 
93
94
  에이전트별 설치 방법은 [`docs/USING.md`](docs/USING.md)를, 구체적인 사용 예시는 위 워크스루 링크를 참고하세요.
@@ -171,7 +172,7 @@ design-ai는 한국 시장을 1순위로 만들어졌고, 글로벌 시장 패
171
172
 
172
173
  ## 상태
173
174
 
174
- 전체 단계 로그는 [`docs/ROADMAP.md`](docs/ROADMAP.md), 현재 완료 범위는 [`docs/PRODUCT-READINESS.md`](docs/PRODUCT-READINESS.md)에서 확인하세요. 현재 **v4.57.0**: public npm publish, provenance-backed GitHub Actions release, public registry smoke, Website Console MCP readiness, workspace learning restore/eval coverage, handoff bundle verification, 90%+ component coverage가 완료됐어요.
175
+ 전체 단계 로그는 [`docs/ROADMAP.md`](docs/ROADMAP.md), 현재 완료 범위는 [`docs/PRODUCT-READINESS.md`](docs/PRODUCT-READINESS.md)에서 확인하세요. 현재 **v4.59.0**: 읽기 전용 Agent SDK(`@design-ai/cli/sdk`), public npm publish, provenance-backed GitHub Actions release, public registry smoke, Website Console MCP readiness, workspace learning restore/eval coverage, handoff bundle verification, 90%+ component coverage가 완료됐어요.
175
176
 
176
177
  핵심 디자인 컨설팅 워크플로우는 로컬 릴리스 기준으로 준비되어 있어요. 웹사이트 개선 컨트롤 타워는 zero-dependency static Web App과 `website-improvement` route/skill/command로 제공되고, Site Profile, audit checklist, MCP readiness, refactor prompt, handoff evidence tracking, bundle export/verify/repair를 한 번에 다뤄요. 로컬 학습 선호도는 `design-ai learn`으로 관리해요 — profile bootstrap, feedback 캡처, 읽기 전용 signal registry, 반복 QA 신호에서 만드는 skill 제안, 그리고 backup/restore/curate/audit까지 전부 로컬에서만 동작하는 opt-in 기능이에요. AI 모델 학습이나 fine-tuning은 여전히 현재 배포 범위 밖이에요.
177
178
 
package/README.md CHANGED
@@ -12,7 +12,7 @@ A model-agnostic design knowledge base + skill system. Drop it in front of any A
12
12
 
13
13
  > **Not a model. Not a fine-tune.** A structured corpus of design expertise + agent-ready instructions that turn a general-purpose LLM into an expert.
14
14
 
15
- > **Distribution status, checked 2026-07-03:** local `npm run release:check` passes, GitHub Pages docs are live, GitHub Release `v4.57.0` is published, `@design-ai/cli@4.57.0` is public on npm (`latest`) with provenance and registry smoke coverage, the Homebrew formula is pinned to `v4.57.0`, and `sungjin.design-ai-vscode@0.4.1` is public on the VS Code Marketplace. The v4.57.0 post-publish live registry smoke hit a stale assertion (fixed on `main`); the package is validated by the pre-publish packed-tarball smoke. See [`docs/external-status.md`](docs/external-status.md).
15
+ > **Distribution status, checked 2026-07-04:** local `npm run release:check` passes, GitHub Pages docs are live, GitHub Release `v4.59.0` is published, `@design-ai/cli@4.59.0` is public on npm (`latest`) with provenance, and the live `npm run registry:smoke` passes cleanly against `@design-ai/cli@4.59.0`. The Homebrew formula is pinned to `v4.59.0`, and `sungjin.design-ai-vscode@0.4.1` is public on the VS Code Marketplace. See [`docs/external-status.md`](docs/external-status.md).
16
16
 
17
17
  ## Coverage at a glance
18
18
 
@@ -89,6 +89,7 @@ See [`docs/DISTRIBUTION.md`](docs/DISTRIBUTION.md) for the full distribution gui
89
89
  | **Aider** | Pass `AGENTS.md` as system prompt. [Walkthrough](docs/integrations/aider-walkthrough.md). |
90
90
  | **Anthropic / OpenAI SDK** | Embed relevant skill `PLAYBOOK.md` files in your prompt. [Walkthrough](docs/integrations/sdk-walkthrough.md). |
91
91
  | **VS Code** | Install the public Marketplace extension for sidebar trees + quick-pick commands. [Walkthrough](docs/integrations/vscode-walkthrough.md). |
92
+ | **Node.js / Agent SDK** | `import { route, prompt, pack, search, recall, check, routes, version } from "@design-ai/cli/sdk"` — call design-ai's deterministic verbs as functions, no CLI shell-out or MCP server needed. Read-only (Phase A). [SDK reference](docs/SDK.md). |
92
93
  | **Plain prompt** | Paste any `skills/*/PLAYBOOK.md` body — each is self-contained. |
93
94
 
94
95
  See [`docs/USING.md`](docs/USING.md) for per-agent setup details, or the linked walkthroughs for concrete example sessions.
@@ -213,7 +214,7 @@ Refresh refs/ on demand: `./tools/extractors/run-all.sh`.
213
214
 
214
215
  ## Status
215
216
 
216
- See [`docs/ROADMAP.md`](docs/ROADMAP.md) for the full phase log and [`docs/PRODUCT-READINESS.md`](docs/PRODUCT-READINESS.md) for the current completion boundary. Currently at **v4.57.0**: public npm publish, provenance-backed GitHub Actions release, public registry smoke, Website Console MCP readiness, workspace learning restore/eval coverage, handoff bundle verification, and 90%+ component coverage are complete.
217
+ See [`docs/ROADMAP.md`](docs/ROADMAP.md) for the full phase log and [`docs/PRODUCT-READINESS.md`](docs/PRODUCT-READINESS.md) for the current completion boundary. Currently at **v4.59.0**: the read-only Agent SDK (`@design-ai/cli/sdk`), public npm publish, provenance-backed GitHub Actions release, public registry smoke, Website Console MCP readiness, workspace learning restore/eval coverage, handoff bundle verification, and 90%+ component coverage are complete.
217
218
 
218
219
  Core design consulting workflows are locally release-ready. The website improvement control tower ships as a zero-dependency static Web App plus a `website-improvement` route/skill/command, covering Site Profiles, audit checklists, MCP readiness, refactor prompts, handoff evidence tracking, and bundle export/verify/repair. Local learning preferences are available through `design-ai learn` — profile bootstrap, feedback capture, a read-only signals registry, skill-proposal generation from repeated QA signals, and full backup/restore/curate/audit tooling, all local-only and opt-in. AI model training or fine-tuning remains outside the shipped scope.
219
220
 
@@ -0,0 +1,36 @@
1
+ // SDK adapter: check(artifact, opts). See docs/AGENT-SDK.md.
2
+ //
3
+ // Read-only: capture is never enabled from the SDK in Phase A (the CLI's
4
+ // `--learn` writes a local learning-profile capture; there is no equivalent
5
+ // opt-in here, consistent with "no file writes" for Phase A).
6
+
7
+ import { checkArtifactContent } from "../lib/check.mjs";
8
+ import { assertKnownRouteId } from "../lib/route.mjs";
9
+ import { optionalBoolean, optionalString, requireNonEmptyString, requireOptions } from "./validate.mjs";
10
+
11
+ /**
12
+ * Check a generated design Markdown artifact for grounding, accessibility,
13
+ * responsive, unresolved-marker, and route-specific requirements. Pure,
14
+ * read-only adapter over `checkArtifactContent` from cli/lib/check.mjs.
15
+ *
16
+ * @param {string} artifact - Markdown artifact content to check.
17
+ * @param {{routeId?: string, strict?: boolean}} [opts]
18
+ * @returns {object} CheckReport — the same shape as `design-ai check --json`.
19
+ */
20
+ export function check(artifact, opts = {}) {
21
+ requireNonEmptyString(artifact, "artifact");
22
+ const options = requireOptions(opts, "check");
23
+
24
+ const routeId = optionalString(options.routeId, "routeId");
25
+ if (routeId) assertKnownRouteId(routeId, { allowEmpty: false });
26
+ // `strict` only affects CLI exit-code behavior; validated for type safety,
27
+ // but the SDK returns the report as-is and lets the caller decide what to
28
+ // do with report.status — there is no process exit code to influence here.
29
+ optionalBoolean(options.strict, "strict", false);
30
+
31
+ return checkArtifactContent({
32
+ content: artifact,
33
+ filePath: "sdk",
34
+ routeId,
35
+ });
36
+ }
@@ -0,0 +1,435 @@
1
+ // Type declarations for the design-ai Agent SDK — Phase A (read-only).
2
+ // Hand-written, zero-build: no TypeScript toolchain is required to produce or
3
+ // ship these. They mirror the runtime shapes exercised by cli/sdk/index.test.mjs
4
+ // (the semver anchor). The eight exported names and their return-shape top-level
5
+ // keys are the stable, semver-covered surface; deeper nested shapes follow the
6
+ // same JSON the CLI's `--json` mode emits.
7
+ //
8
+ // Import: `import { route, search } from "@design-ai/cli/sdk";`
9
+
10
+ // ── Shared building blocks ────────────────────────────────────────────────
11
+
12
+ /** A curated reference (skill/agent/knowledge/command) and whether it exists on disk. */
13
+ export interface RouteReference {
14
+ path: string;
15
+ exists: boolean;
16
+ }
17
+
18
+ /** One reference-coverage tally (available vs total) within a route explanation. */
19
+ export interface CoverageCount {
20
+ available: number;
21
+ total: number;
22
+ }
23
+
24
+ export interface ReferenceCoverage {
25
+ command: CoverageCount;
26
+ skills: CoverageCount;
27
+ agents: CoverageCount;
28
+ knowledge: CoverageCount;
29
+ total: CoverageCount;
30
+ }
31
+
32
+ export interface ScoreBreakdownEntry {
33
+ label: string;
34
+ value: number;
35
+ }
36
+
37
+ export interface RouteExplanation {
38
+ summary: string;
39
+ scoreBreakdown: ScoreBreakdownEntry[];
40
+ referenceCoverage: ReferenceCoverage;
41
+ missingReferences: string[];
42
+ }
43
+
44
+ /** Advisory brief-relevant knowledge recalled by the shared lexical scorer. */
45
+ export interface RelatedKnowledge {
46
+ id: string;
47
+ score: number;
48
+ matchedTokens: string[];
49
+ }
50
+
51
+ export type RouteConfidence = "high" | "medium" | "low" | "catalog" | "forced";
52
+
53
+ export interface RouteResult {
54
+ id: string;
55
+ label: string;
56
+ score: number;
57
+ confidence: RouteConfidence;
58
+ matchedKeywords: string[];
59
+ command: RouteReference | null;
60
+ skills: RouteReference[];
61
+ agents: RouteReference[];
62
+ knowledge: RouteReference[];
63
+ keywords: string[];
64
+ explanation: RouteExplanation;
65
+ /** Present only when `route(brief, { explain: true })` is requested. */
66
+ relatedKnowledge?: RelatedKnowledge[];
67
+ /** Present only when a route was forced via `routeId`. */
68
+ forced?: boolean;
69
+ /** Present only when the fallback route was used. */
70
+ fallback?: boolean;
71
+ }
72
+
73
+ export interface RouteCatalog {
74
+ version: string;
75
+ routes: RouteResult[];
76
+ }
77
+
78
+ // ── prompt / pack ─────────────────────────────────────────────────────────
79
+
80
+ export interface ReferenceExample {
81
+ relPath: string;
82
+ title: string;
83
+ category: string;
84
+ score: number;
85
+ preview: string;
86
+ }
87
+
88
+ /** A single recalled learning-profile entry. */
89
+ export interface LearningRecallEntry {
90
+ id: string;
91
+ category: string;
92
+ score: number;
93
+ matchedTokens: string[];
94
+ text: string;
95
+ }
96
+
97
+ /** A single recalled shipped-corpus knowledge entry. */
98
+ export interface CorpusRecallEntry {
99
+ id: string;
100
+ score: number;
101
+ matchedTokens: string[];
102
+ }
103
+
104
+ /** Recall block embedded in a prompt plan when `withRecall: true`. */
105
+ export interface PromptRecall {
106
+ query: string;
107
+ mode: string;
108
+ candidateCount: number;
109
+ selectedCount: number;
110
+ selected: CorpusRecallEntry[];
111
+ markdown: string;
112
+ }
113
+
114
+ /** A stored learning-profile entry, as surfaced in a prompt plan's learning context. */
115
+ export interface LearningEntry {
116
+ id: string;
117
+ category: string;
118
+ text: string;
119
+ source: string;
120
+ createdAt: string;
121
+ }
122
+
123
+ export interface LearningSelection {
124
+ mode: string;
125
+ query: string;
126
+ candidateCount: number;
127
+ matchedCount: number;
128
+ queryTokenCount: number;
129
+ fallbackEnabled: boolean;
130
+ selectedCount: number;
131
+ fallbackCount: number;
132
+ selected: LearningRecallEntry[];
133
+ }
134
+
135
+ export interface LearningAuditSummary {
136
+ status: string;
137
+ failures: number;
138
+ warnings: number;
139
+ }
140
+
141
+ /** Learning context embedded in a prompt plan when `withLearning: true`. */
142
+ export interface LearningContext {
143
+ file: string;
144
+ category: string;
145
+ limit: number;
146
+ query: string;
147
+ selection: LearningSelection;
148
+ entries: LearningEntry[];
149
+ empty: boolean;
150
+ auditSummary: LearningAuditSummary;
151
+ markdown: string;
152
+ }
153
+
154
+ export interface PromptPlan {
155
+ brief: string;
156
+ version: string;
157
+ route: RouteResult;
158
+ slashCommand: string;
159
+ referenceExamples: ReferenceExample[];
160
+ filesToRead: string[];
161
+ checklist: string[];
162
+ qualityCommand: string;
163
+ prompt: string;
164
+ /** Present only when `prompt(brief, { withLearning: true })` is requested. */
165
+ learningContext?: LearningContext;
166
+ /** Present only when `prompt(brief, { withRecall: true })` is requested. */
167
+ recall?: PromptRecall;
168
+ }
169
+
170
+ export interface PackSummary {
171
+ totalFiles: number;
172
+ includedFiles: number;
173
+ truncatedFiles: number;
174
+ missingFiles: number;
175
+ usedBytes: number;
176
+ maxBytes: number;
177
+ remainingBytes: number;
178
+ usedRatio: number;
179
+ status: string;
180
+ }
181
+
182
+ export interface PackFile {
183
+ path: string;
184
+ bytes: number;
185
+ includedBytes: number;
186
+ included: boolean;
187
+ truncated: boolean;
188
+ content: string;
189
+ }
190
+
191
+ export interface Pack {
192
+ brief: string;
193
+ version: string;
194
+ maxBytes: number;
195
+ usedBytes: number;
196
+ summary: PackSummary;
197
+ warnings: string[];
198
+ plan: PromptPlan;
199
+ files: PackFile[];
200
+ markdown: string;
201
+ }
202
+
203
+ // ── search ────────────────────────────────────────────────────────────────
204
+
205
+ /** A plain line hit (default `search`). */
206
+ export interface SearchHit {
207
+ file: string;
208
+ lineNumber: number;
209
+ relPath: string;
210
+ preview: string;
211
+ }
212
+
213
+ /** A ranked hit (`search(query, { ranked: true })`) with a BM25 score. */
214
+ export interface RankedSearchHit {
215
+ relPath: string;
216
+ file: string;
217
+ score: number;
218
+ matchedTokens: string[];
219
+ preview: string;
220
+ }
221
+
222
+ // ── recall ────────────────────────────────────────────────────────────────
223
+
224
+ export interface RecallCorpus {
225
+ candidateCount: number;
226
+ selectedCount: number;
227
+ selected: CorpusRecallEntry[];
228
+ }
229
+
230
+ export interface RecallLearning {
231
+ mode: string;
232
+ candidateCount: number;
233
+ selectedCount: number;
234
+ selected: LearningRecallEntry[];
235
+ }
236
+
237
+ export interface RecallResult {
238
+ corpus: RecallCorpus;
239
+ learning: RecallLearning;
240
+ }
241
+
242
+ // ── check ─────────────────────────────────────────────────────────────────
243
+
244
+ export type CheckLevel = "pass" | "warn" | "fail";
245
+
246
+ export interface CheckResult {
247
+ id: string;
248
+ title: string;
249
+ level: CheckLevel;
250
+ passed: boolean;
251
+ message: string;
252
+ /** Present only when the check has supporting evidence. */
253
+ evidence?: string;
254
+ }
255
+
256
+ export interface CheckReport {
257
+ filePath: string;
258
+ /** Present only when a `routeId` was supplied. */
259
+ routeId?: string;
260
+ status: CheckLevel;
261
+ passes: number;
262
+ warnings: number;
263
+ failures: number;
264
+ total: number;
265
+ /** Human-readable ratio, e.g. "6/8". */
266
+ score: string;
267
+ results: CheckResult[];
268
+ }
269
+
270
+ export interface VersionReport {
271
+ cli: string;
272
+ corpus: string;
273
+ }
274
+
275
+ // ── Option objects ────────────────────────────────────────────────────────
276
+
277
+ export interface RouteOptions {
278
+ /** Max routes to return. Default 3, range 1–10. */
279
+ limit?: number;
280
+ /** Include the advisory explanation + related-knowledge section. Default false. */
281
+ explain?: boolean;
282
+ }
283
+
284
+ export interface PromptOptions {
285
+ /** Force a specific route id instead of scoring the brief. */
286
+ routeId?: string;
287
+ /** Include local learning-profile guidance (read-only; never recorded). Default false. */
288
+ withLearning?: boolean;
289
+ /** Restrict learning guidance to a category. */
290
+ learningCategory?: string;
291
+ /** Max learning entries. Range 1–100. */
292
+ learningLimit?: number;
293
+ /** Include a brief-relevant corpus recall block. Default false. */
294
+ withRecall?: boolean;
295
+ /** Max recall entries. Range 1–20. */
296
+ recallLimit?: number;
297
+ }
298
+
299
+ export interface PackOptions extends PromptOptions {
300
+ /** Byte budget for the bundled context files. Default 120000, range 1000–1000000. */
301
+ maxBytes?: number;
302
+ }
303
+
304
+ export interface SearchOptions {
305
+ /** Restrict to one corpus directory (must be a known search dir). */
306
+ dir?: string;
307
+ /** Max hits. Default 20, range 1–500. */
308
+ limit?: number;
309
+ /** Return ranked BM25 hits (score + matchedTokens) instead of plain line hits. */
310
+ ranked?: boolean;
311
+ }
312
+
313
+ export interface RecallOptions {
314
+ /** Max entries per side (corpus/learning). Range 1–20. */
315
+ limit?: number;
316
+ /** Restrict learning recall to a category. */
317
+ category?: string;
318
+ }
319
+
320
+ export interface CheckOptions {
321
+ /** Apply route-specific requirements for this route id. */
322
+ routeId?: string;
323
+ /** Validated for parity with the CLI; has no effect in-process (no exit code). */
324
+ strict?: boolean;
325
+ }
326
+
327
+ // ── The eight Phase A verbs ─────────────────────────────────────────────────
328
+
329
+ /** Recommend the best route(s), commands, skills, and knowledge for a brief. */
330
+ export function route(brief: string, opts?: RouteOptions): RouteResult[];
331
+
332
+ /** List the full route catalog independent of any brief. */
333
+ export function routes(): RouteCatalog;
334
+
335
+ /** Build a ready-to-use agent prompt plan from a brief. */
336
+ export function prompt(brief: string, opts?: PromptOptions): PromptPlan;
337
+
338
+ /** Build a prompt plan plus a bounded context-file bundle from a brief. */
339
+ export function pack(brief: string, opts?: PackOptions): Pack;
340
+
341
+ /** Search the local corpus. Returns ranked hits when `ranked: true`, else plain line hits. */
342
+ export function search(query: string, opts: SearchOptions & { ranked: true }): RankedSearchHit[];
343
+ export function search(query: string, opts?: SearchOptions): SearchHit[];
344
+
345
+ /** Recall brief-relevant corpus knowledge and local learning-profile entries. */
346
+ export function recall(query: string, opts?: RecallOptions): RecallResult;
347
+
348
+ /** Check a Markdown artifact's content for grounding, accessibility, and route requirements. */
349
+ export function check(artifact: string, opts?: CheckOptions): CheckReport;
350
+
351
+ /** Report the CLI package version and the plugin/corpus version. */
352
+ export function version(): VersionReport;
353
+
354
+ // ── learn.* (Phase B — local writes) ─────────────────────────────────────
355
+ //
356
+ // The ONLY writing verbs in the SDK. Each writes exclusively to the local
357
+ // learning profile (`DESIGN_AI_LEARNING_FILE` / defaultLearningFile()), never
358
+ // the network. There is no `filePath` or `now`/timestamp option on any of
359
+ // these — target a specific profile via the `DESIGN_AI_LEARNING_FILE` env
360
+ // var, exactly like the CLI. See docs/SDK.md "Phase B — local writes".
361
+
362
+ export interface LearnRememberOptions {
363
+ /** Learning-profile category. Default "preference". */
364
+ category?: string;
365
+ }
366
+
367
+ export interface LearnFeedbackOptions {
368
+ /** Feedback outcome; normalized by the underlying lib (e.g. "keep" | "avoid" | "improve"). Default "improve". */
369
+ outcome?: string;
370
+ /** Learning-profile category. Default "workflow". */
371
+ category?: string;
372
+ }
373
+
374
+ export interface LearnCaptureOptions {
375
+ /** Add route-specific check requirements for this route id before capturing. */
376
+ routeId?: string;
377
+ }
378
+
379
+ /** A single stored learning-profile entry, as written by learn.remember/feedback/captureFromCheck. */
380
+ export interface LearningProfileEntry {
381
+ id: string;
382
+ category: string;
383
+ text: string;
384
+ source: string;
385
+ createdAt: string;
386
+ }
387
+
388
+ export interface LearningProfile {
389
+ version: number;
390
+ updatedAt: string;
391
+ entries: LearningProfileEntry[];
392
+ }
393
+
394
+ /** Return shape of learn.remember() and learn.feedback(). */
395
+ export interface RememberResult {
396
+ file: string;
397
+ entry: LearningProfileEntry;
398
+ profile: LearningProfile;
399
+ }
400
+
401
+ /** An entry skipped by learn.captureFromCheck() because it duplicates an existing profile entry. */
402
+ export interface CaptureSkippedEntry {
403
+ category: string;
404
+ text: string;
405
+ source: string;
406
+ reason: string;
407
+ }
408
+
409
+ /** Return shape of learn.captureFromCheck() — the `captureLearningEntries` result. */
410
+ export interface CaptureResult {
411
+ file: string;
412
+ dryRun: boolean;
413
+ applied: boolean;
414
+ source: string;
415
+ candidateCount: number;
416
+ addedCount: number;
417
+ skippedCount: number;
418
+ count: number;
419
+ entries: LearningProfileEntry[];
420
+ skipped: CaptureSkippedEntry[];
421
+ }
422
+
423
+ /**
424
+ * Phase B: the explicit, opt-in LOCAL-WRITE namespace. `learn.remember`,
425
+ * `learn.feedback`, and `learn.captureFromCheck` are the only SDK verbs that
426
+ * write files — each writes only the local learning profile.
427
+ */
428
+ export declare const learn: {
429
+ /** Record a local learning-profile preference. */
430
+ remember(text: string, opts?: LearnRememberOptions): RememberResult;
431
+ /** Record feedback (keep/avoid/improve) as a local learning-profile entry. */
432
+ feedback(text: string, opts?: LearnFeedbackOptions): RememberResult;
433
+ /** Check a Markdown artifact and capture its non-pass results as local learning-profile entries. */
434
+ captureFromCheck(artifact: string, opts?: LearnCaptureOptions): CaptureResult;
435
+ };
@@ -0,0 +1,30 @@
1
+ // design-ai Agent SDK — Phase A (read-only) + Phase B (local writes). See
2
+ // docs/AGENT-SDK.md and docs/SDK.md.
3
+ //
4
+ // A curated, semver-stable adapter over the same cli/lib functions the CLI and
5
+ // MCP server call. Each verb validates its inputs, resolves the package root
6
+ // the same way the CLI does, and returns a plain JSON-serializable object —
7
+ // the same shape the CLI's --json mode emits. No network calls, no runtime
8
+ // dependencies. The 8 Phase A verbs below perform no file writes: no
9
+ // learning-usage sidecar writes, even from prompt/pack's withLearning option.
10
+ //
11
+ // Phase B adds a single `learn` namespace grouping the three explicit,
12
+ // opt-in LOCAL-WRITE verbs (`learn.remember`, `learn.feedback`,
13
+ // `learn.captureFromCheck`). This keeps the write boundary explicit: the 8
14
+ // Phase A verbs stay read-only and unchanged; `learn` is the only place the
15
+ // SDK writes files, and it only ever writes the local learning profile.
16
+ //
17
+ // Import path: `@design-ai/cli/sdk` (see the "exports" map in package.json).
18
+ // `cli/lib/*` stays internal and unstable; this barrel is the only supported
19
+ // public surface. Do not import `cli/lib/*.mjs` directly from outside this
20
+ // package — only the 8 named function exports plus the `learn` namespace
21
+ // below are covered by the semver stability contract described in docs/SDK.md.
22
+
23
+ export { check } from "./check-adapter.mjs";
24
+ export { learn } from "./learn-adapter.mjs";
25
+ export { pack } from "./pack-adapter.mjs";
26
+ export { prompt } from "./prompt-adapter.mjs";
27
+ export { recall } from "./recall-adapter.mjs";
28
+ export { route, routes } from "./route-adapter.mjs";
29
+ export { search } from "./search-adapter.mjs";
30
+ export { version } from "./version-adapter.mjs";