@rien7/design-surface 0.0.0-stage → 0.1.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/bin/design-surface.mjs +286 -0
- package/dist/cli/init.mjs +411 -0
- package/dist/cli/propose.mjs +172 -0
- package/dist/cli/reviewOps.mjs +127 -0
- package/dist/editor/AgentProposalCard.d.ts +10 -0
- package/dist/editor/AgentProposalCard.d.ts.map +1 -0
- package/dist/editor/AgentProposalCard.js +28 -0
- package/dist/editor/AgentProposalCard.js.map +1 -0
- package/dist/editor/App.d.ts +2 -0
- package/dist/editor/App.d.ts.map +1 -0
- package/dist/editor/App.js +1813 -0
- package/dist/editor/App.js.map +1 -0
- package/dist/editor/CanvasHud.d.ts +12 -0
- package/dist/editor/CanvasHud.d.ts.map +1 -0
- package/dist/editor/CanvasHud.js +13 -0
- package/dist/editor/CanvasHud.js.map +1 -0
- package/dist/editor/CanvasSurface.d.ts +20 -0
- package/dist/editor/CanvasSurface.d.ts.map +1 -0
- package/dist/editor/CanvasSurface.js +252 -0
- package/dist/editor/CanvasSurface.js.map +1 -0
- package/dist/editor/Changes.d.ts +17 -0
- package/dist/editor/Changes.d.ts.map +1 -0
- package/dist/editor/Changes.js +59 -0
- package/dist/editor/Changes.js.map +1 -0
- package/dist/editor/CommentPopover.d.ts +17 -0
- package/dist/editor/CommentPopover.d.ts.map +1 -0
- package/dist/editor/CommentPopover.js +62 -0
- package/dist/editor/CommentPopover.js.map +1 -0
- package/dist/editor/Comments.d.ts +13 -0
- package/dist/editor/Comments.d.ts.map +1 -0
- package/dist/editor/Comments.js +39 -0
- package/dist/editor/Comments.js.map +1 -0
- package/dist/editor/History.d.ts +7 -0
- package/dist/editor/History.d.ts.map +1 -0
- package/dist/editor/History.js +43 -0
- package/dist/editor/History.js.map +1 -0
- package/dist/editor/Inspector.d.ts +22 -0
- package/dist/editor/Inspector.d.ts.map +1 -0
- package/dist/editor/Inspector.js +241 -0
- package/dist/editor/Inspector.js.map +1 -0
- package/dist/editor/LazyMount.d.ts +10 -0
- package/dist/editor/LazyMount.d.ts.map +1 -0
- package/dist/editor/LazyMount.js +29 -0
- package/dist/editor/LazyMount.js.map +1 -0
- package/dist/editor/LocaleSwitch.d.ts +2 -0
- package/dist/editor/LocaleSwitch.d.ts.map +1 -0
- package/dist/editor/LocaleSwitch.js +13 -0
- package/dist/editor/LocaleSwitch.js.map +1 -0
- package/dist/editor/NodeInspector.d.ts +9 -0
- package/dist/editor/NodeInspector.d.ts.map +1 -0
- package/dist/editor/NodeInspector.js +9 -0
- package/dist/editor/NodeInspector.js.map +1 -0
- package/dist/editor/PreviewFrame.d.ts +10 -0
- package/dist/editor/PreviewFrame.d.ts.map +1 -0
- package/dist/editor/PreviewFrame.js +22 -0
- package/dist/editor/PreviewFrame.js.map +1 -0
- package/dist/editor/ProjectIndex.d.ts +12 -0
- package/dist/editor/ProjectIndex.d.ts.map +1 -0
- package/dist/editor/ProjectIndex.js +43 -0
- package/dist/editor/ProjectIndex.js.map +1 -0
- package/dist/editor/StyleEditor.d.ts +37 -0
- package/dist/editor/StyleEditor.d.ts.map +1 -0
- package/dist/editor/StyleEditor.js +275 -0
- package/dist/editor/StyleEditor.js.map +1 -0
- package/dist/editor/TokenWorkbench.d.ts +37 -0
- package/dist/editor/TokenWorkbench.d.ts.map +1 -0
- package/dist/editor/TokenWorkbench.js +146 -0
- package/dist/editor/TokenWorkbench.js.map +1 -0
- package/dist/editor/Tokens.d.ts +21 -0
- package/dist/editor/Tokens.d.ts.map +1 -0
- package/dist/editor/Tokens.js +56 -0
- package/dist/editor/Tokens.js.map +1 -0
- package/dist/editor/VariablesPage.d.ts +28 -0
- package/dist/editor/VariablesPage.d.ts.map +1 -0
- package/dist/editor/VariablesPage.js +14 -0
- package/dist/editor/VariablesPage.js.map +1 -0
- package/dist/editor/api.d.ts +13 -0
- package/dist/editor/api.d.ts.map +1 -0
- package/dist/editor/api.js +70 -0
- package/dist/editor/api.js.map +1 -0
- package/dist/editor/camera.d.ts +18 -0
- package/dist/editor/camera.d.ts.map +1 -0
- package/dist/editor/camera.js +40 -0
- package/dist/editor/camera.js.map +1 -0
- package/dist/editor/canvas.d.ts +26 -0
- package/dist/editor/canvas.d.ts.map +1 -0
- package/dist/editor/canvas.js +51 -0
- package/dist/editor/canvas.js.map +1 -0
- package/dist/editor/chrome/EditorChrome.d.ts +42 -0
- package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
- package/dist/editor/chrome/EditorChrome.js +21 -0
- package/dist/editor/chrome/EditorChrome.js.map +1 -0
- package/dist/editor/i18n.d.ts +18 -0
- package/dist/editor/i18n.d.ts.map +1 -0
- package/dist/editor/i18n.js +762 -0
- package/dist/editor/i18n.js.map +1 -0
- package/dist/editor/main.d.ts +3 -0
- package/dist/editor/main.d.ts.map +1 -0
- package/dist/editor/main.js +12 -0
- package/dist/editor/main.js.map +1 -0
- package/dist/editor/model.d.ts +17 -0
- package/dist/editor/model.d.ts.map +1 -0
- package/dist/editor/model.js +12 -0
- package/dist/editor/model.js.map +1 -0
- package/dist/editor/reviewLifecycle.d.ts +9 -0
- package/dist/editor/reviewLifecycle.d.ts.map +1 -0
- package/dist/editor/reviewLifecycle.js +30 -0
- package/dist/editor/reviewLifecycle.js.map +1 -0
- package/dist/editor/styles.css +6626 -0
- package/dist/editor/ui/Button.d.ts +3 -0
- package/dist/editor/ui/Button.d.ts.map +1 -0
- package/dist/editor/ui/Button.js +6 -0
- package/dist/editor/ui/Button.js.map +1 -0
- package/dist/editor/ui/CommentBox.d.ts +23 -0
- package/dist/editor/ui/CommentBox.d.ts.map +1 -0
- package/dist/editor/ui/CommentBox.js +41 -0
- package/dist/editor/ui/CommentBox.js.map +1 -0
- package/dist/editor/ui/Icon.d.ts +9 -0
- package/dist/editor/ui/Icon.d.ts.map +1 -0
- package/dist/editor/ui/Icon.js +6 -0
- package/dist/editor/ui/Icon.js.map +1 -0
- package/dist/editor/ui/IconButton.d.ts +11 -0
- package/dist/editor/ui/IconButton.d.ts.map +1 -0
- package/dist/editor/ui/IconButton.js +6 -0
- package/dist/editor/ui/IconButton.js.map +1 -0
- package/dist/editor/ui/NumberInput.d.ts +14 -0
- package/dist/editor/ui/NumberInput.d.ts.map +1 -0
- package/dist/editor/ui/NumberInput.js +6 -0
- package/dist/editor/ui/NumberInput.js.map +1 -0
- package/dist/editor/ui/PageLine.d.ts +14 -0
- package/dist/editor/ui/PageLine.d.ts.map +1 -0
- package/dist/editor/ui/PageLine.js +7 -0
- package/dist/editor/ui/PageLine.js.map +1 -0
- package/dist/editor/ui/Select.d.ts +15 -0
- package/dist/editor/ui/Select.d.ts.map +1 -0
- package/dist/editor/ui/Select.js +11 -0
- package/dist/editor/ui/Select.js.map +1 -0
- package/dist/editor/ui/TokenField.d.ts +14 -0
- package/dist/editor/ui/TokenField.d.ts.map +1 -0
- package/dist/editor/ui/TokenField.js +41 -0
- package/dist/editor/ui/TokenField.js.map +1 -0
- package/dist/editor-ui.d.ts +14 -0
- package/dist/editor-ui.d.ts.map +1 -0
- package/dist/editor-ui.js +13 -0
- package/dist/editor-ui.js.map +1 -0
- package/dist/inspector/runtime.d.ts +18 -0
- package/dist/inspector/runtime.d.ts.map +1 -0
- package/dist/inspector/runtime.js +987 -0
- package/dist/inspector/runtime.js.map +1 -0
- package/dist/preview/main.d.ts +3 -0
- package/dist/preview/main.d.ts.map +1 -0
- package/dist/preview/main.js +72 -0
- package/dist/preview/main.js.map +1 -0
- package/dist/preview/preview.css +39 -0
- package/dist/runtime/flow.d.ts +15 -0
- package/dist/runtime/flow.d.ts.map +1 -0
- package/dist/runtime/flow.js +48 -0
- package/dist/runtime/flow.js.map +1 -0
- package/dist/runtime/free.d.ts +18 -0
- package/dist/runtime/free.d.ts.map +1 -0
- package/dist/runtime/free.js +8 -0
- package/dist/runtime/free.js.map +1 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +46 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/types.d.ts +57 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +14 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/shared/prompt.d.mts +13 -0
- package/dist/shared/prompt.mjs +97 -0
- package/dist/shared/protocol.d.ts +79 -0
- package/dist/shared/protocol.d.ts.map +1 -0
- package/dist/shared/protocol.js +7 -0
- package/dist/shared/protocol.js.map +1 -0
- package/dist/shared/tokens.d.ts +66 -0
- package/dist/shared/tokens.d.ts.map +1 -0
- package/dist/shared/tokens.js +2 -0
- package/dist/shared/tokens.js.map +1 -0
- package/dist/shared/types.d.ts +301 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +13 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tokens/adapters/css.mjs +44 -0
- package/dist/tokens/adapters/cssInCode.mjs +277 -0
- package/dist/tokens/adapters/oxcShared.mjs +59 -0
- package/dist/tokens/adapters/preprocessor.mjs +63 -0
- package/dist/tokens/adapters/registry.mjs +53 -0
- package/dist/tokens/adapters/tailwindcss.mjs +360 -0
- package/dist/tokens/adapters/types.mjs +117 -0
- package/dist/tokens/extract.mjs +328 -0
- package/dist/tokens/pipeline.mjs +688 -0
- package/dist/vite/events.d.ts +25 -0
- package/dist/vite/events.d.ts.map +1 -0
- package/dist/vite/events.js +137 -0
- package/dist/vite/events.js.map +1 -0
- package/dist/vite/layout.d.ts +4 -0
- package/dist/vite/layout.d.ts.map +1 -0
- package/dist/vite/layout.js +78 -0
- package/dist/vite/layout.js.map +1 -0
- package/dist/vite/plugin.d.ts +33 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +403 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/review.d.ts +7 -0
- package/dist/vite/review.d.ts.map +1 -0
- package/dist/vite/review.js +334 -0
- package/dist/vite/review.js.map +1 -0
- package/package.json +87 -4
- package/skills/design-surface/SKILL.md +190 -0
- package/skills/design-surface-authoring/SKILL.md +257 -0
- package/skills/design-surface-tokens/SKILL.md +235 -0
- package/README.md +0 -3
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { dirname, join, resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { colorToRgb, loadTokenConfig } from '../tokens/pipeline.mjs'
|
|
5
|
+
|
|
6
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/
|
|
7
|
+
const VALID_ACTIONS = new Set(['create', 'update', 'alias', 'merge'])
|
|
8
|
+
const VALID_TIERS = new Set(['primitive', 'semantic', 'component'])
|
|
9
|
+
const VALID_TYPES = new Set(['color', 'length', 'text'])
|
|
10
|
+
const VALUE_FLAGS = new Set(['name', 'value', 'tier', 'alias', 'type', 'action', 'rationale'])
|
|
11
|
+
|
|
12
|
+
function parseArgs(argv) {
|
|
13
|
+
const flags = {}
|
|
14
|
+
const positionals = []
|
|
15
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
16
|
+
const token = argv[i]
|
|
17
|
+
if (token.startsWith('--')) {
|
|
18
|
+
const eq = token.indexOf('=')
|
|
19
|
+
if (eq > 2) {
|
|
20
|
+
const key = token.slice(2, eq)
|
|
21
|
+
if (!VALUE_FLAGS.has(key)) throw new Error(`unknown option: --${key}`)
|
|
22
|
+
flags[key] = token.slice(eq + 1)
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
const key = token.slice(2)
|
|
26
|
+
if (!VALUE_FLAGS.has(key)) throw new Error(`unknown option: --${key}`)
|
|
27
|
+
const next = argv[i + 1]
|
|
28
|
+
if (next === undefined) throw new Error(`--${key} requires a value`)
|
|
29
|
+
flags[key] = next
|
|
30
|
+
i += 1
|
|
31
|
+
continue
|
|
32
|
+
}
|
|
33
|
+
positionals.push(token)
|
|
34
|
+
}
|
|
35
|
+
return { flags, positionals }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function inferTokenType(value, targetType) {
|
|
39
|
+
if (targetType === 'color') return 'color'
|
|
40
|
+
if (targetType === 'dimension') return 'length'
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
const trimmed = value.trim()
|
|
43
|
+
if (/^-?\d+(?:\.\d+)?(px|rem|em|%)$/.test(trimmed)) return 'length'
|
|
44
|
+
if (
|
|
45
|
+
colorToRgb(trimmed) ||
|
|
46
|
+
/^(?:color-mix|rgba?|hsla?|oklch|oklab|color)\(/i.test(trimmed)
|
|
47
|
+
) {
|
|
48
|
+
return 'color'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return 'text'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function readJson(file) {
|
|
55
|
+
if (!existsSync(file)) return null
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(readFileSync(file, 'utf8'))
|
|
58
|
+
} catch {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function proposeToken({ root = process.cwd(), argv = [] } = {}) {
|
|
64
|
+
const { flags, positionals } = parseArgs(argv)
|
|
65
|
+
const design = positionals[0]
|
|
66
|
+
if (!design) throw new Error('propose token requires a <design> id')
|
|
67
|
+
if (!SAFE_ID.test(design)) throw new Error(`Invalid design id: ${design}`)
|
|
68
|
+
|
|
69
|
+
const name = flags.name
|
|
70
|
+
if (!name || !/^--[a-zA-Z0-9_-]+$/.test(name)) {
|
|
71
|
+
throw new Error('--name is required and must be a CSS custom property starting with "--"')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const action = flags.action ?? 'create'
|
|
75
|
+
if (!VALID_ACTIONS.has(action)) {
|
|
76
|
+
throw new Error(`Invalid --action "${action}". Expected one of: create, update, alias, merge`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const tier = flags.tier ?? 'semantic'
|
|
80
|
+
if (!VALID_TIERS.has(tier)) {
|
|
81
|
+
throw new Error(`Invalid --tier "${tier}". Expected one of: primitive, semantic, component`)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const alias = flags.alias
|
|
85
|
+
if (alias !== undefined) {
|
|
86
|
+
if (!alias || alias.startsWith('--')) {
|
|
87
|
+
throw new Error('--alias must be a DTCG dot-path (e.g. color.surface), not a CSS variable name')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if ((action === 'alias' || action === 'merge') && !alias) {
|
|
91
|
+
throw new Error(`--alias is required when --action is ${action}`)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const value = flags.value ?? (action === 'alias' || action === 'merge' ? alias : undefined)
|
|
95
|
+
if ((action === 'create' || action === 'update') && !value) {
|
|
96
|
+
throw new Error(`--value is required when --action is ${action}`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let manifestPath = join(root, 'design/tokens.manifest.json')
|
|
100
|
+
try {
|
|
101
|
+
const config = loadTokenConfig(root)
|
|
102
|
+
manifestPath = resolve(root, config.manifestOut)
|
|
103
|
+
} catch {
|
|
104
|
+
// fallback to default manifest path
|
|
105
|
+
}
|
|
106
|
+
const manifest = readJson(manifestPath)
|
|
107
|
+
const manifestTokens = Array.isArray(manifest?.tokens) ? manifest.tokens : []
|
|
108
|
+
const existingToken = manifestTokens.find((entry) => entry.cssName === name)
|
|
109
|
+
const aliasTarget = alias ? manifestTokens.find((entry) => entry.path === alias) : undefined
|
|
110
|
+
|
|
111
|
+
const tokenType = flags.type ?? inferTokenType(value, aliasTarget?.type)
|
|
112
|
+
if (!VALID_TYPES.has(tokenType)) {
|
|
113
|
+
throw new Error(`Invalid --type "${tokenType}". Expected one of: color, length, text`)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const source = `design/tokens/${tier}.tokens.json`
|
|
117
|
+
const sourceHash = typeof manifest?.sourceHash === 'string' ? manifest.sourceHash : ''
|
|
118
|
+
const reviewPath = resolve(root, 'design', design, 'review.json')
|
|
119
|
+
const existingReview = readJson(reviewPath)
|
|
120
|
+
const now = new Date().toISOString()
|
|
121
|
+
|
|
122
|
+
const items = Array.isArray(existingReview?.items) ? [...existingReview.items] : []
|
|
123
|
+
const batches = Array.isArray(existingReview?.batches) ? [...existingReview.batches] : []
|
|
124
|
+
const id = `token-propose-${name}`
|
|
125
|
+
const existingIndex = items.findIndex(
|
|
126
|
+
(entry) =>
|
|
127
|
+
entry.id === id ||
|
|
128
|
+
(entry.kind === 'token' &&
|
|
129
|
+
entry.author === 'agent' &&
|
|
130
|
+
entry.target?.type === 'token' &&
|
|
131
|
+
entry.target.token === name &&
|
|
132
|
+
entry.status !== 'archived'),
|
|
133
|
+
)
|
|
134
|
+
const prev = existingIndex >= 0 ? items[existingIndex] : null
|
|
135
|
+
|
|
136
|
+
const item = {
|
|
137
|
+
id: prev?.id ?? id,
|
|
138
|
+
design,
|
|
139
|
+
kind: 'token',
|
|
140
|
+
scope: 'design',
|
|
141
|
+
author: 'agent',
|
|
142
|
+
target: { type: 'token', token: name },
|
|
143
|
+
from: action === 'create' ? '' : existingToken?.value ?? prev?.from ?? '',
|
|
144
|
+
to: value,
|
|
145
|
+
source,
|
|
146
|
+
...(sourceHash ? { sourceHash } : {}),
|
|
147
|
+
tokenType,
|
|
148
|
+
tokenAction: action,
|
|
149
|
+
...(alias ? { tokenAlias: alias } : {}),
|
|
150
|
+
tokenTier: tier,
|
|
151
|
+
...(flags.rationale ? { rationale: flags.rationale } : {}),
|
|
152
|
+
status: 'open',
|
|
153
|
+
createdAt: prev?.createdAt ?? now,
|
|
154
|
+
updatedAt: now,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (existingIndex >= 0) items[existingIndex] = item
|
|
158
|
+
else items.push(item)
|
|
159
|
+
|
|
160
|
+
const nextReview = {
|
|
161
|
+
version: 1,
|
|
162
|
+
design,
|
|
163
|
+
updatedAt: now,
|
|
164
|
+
items,
|
|
165
|
+
batches,
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
mkdirSync(dirname(reviewPath), { recursive: true })
|
|
169
|
+
writeFileSync(reviewPath, `${JSON.stringify(nextReview, null, 2)}\n`)
|
|
170
|
+
|
|
171
|
+
return { item, reviewPath }
|
|
172
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import crypto from 'node:crypto'
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/
|
|
6
|
+
const VALID_STATUSES = new Set(['in_progress', 'resolved'])
|
|
7
|
+
|
|
8
|
+
function loadReviewForMutation(root, design) {
|
|
9
|
+
if (!design) throw new Error('design id is required')
|
|
10
|
+
if (!SAFE_ID.test(design)) throw new Error(`Invalid design id: ${design}`)
|
|
11
|
+
const file = resolve(root, 'design', design, 'review.json')
|
|
12
|
+
if (!existsSync(file)) throw new Error(`no review ledger for ${design}`)
|
|
13
|
+
let parsed
|
|
14
|
+
try {
|
|
15
|
+
parsed = JSON.parse(readFileSync(file, 'utf8'))
|
|
16
|
+
} catch {
|
|
17
|
+
throw new Error(`failed to parse review ledger for ${design}`)
|
|
18
|
+
}
|
|
19
|
+
if (!parsed || parsed.version !== 1 || !Array.isArray(parsed.items)) {
|
|
20
|
+
throw new Error(`invalid review ledger shape for ${design}`)
|
|
21
|
+
}
|
|
22
|
+
return { file, review: parsed }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function saveReviewMutation(file, review, now) {
|
|
26
|
+
const next = {
|
|
27
|
+
...review,
|
|
28
|
+
updatedAt: now,
|
|
29
|
+
}
|
|
30
|
+
writeFileSync(file, `${JSON.stringify(next, null, 2)}\n`)
|
|
31
|
+
return next
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function replyReviewItem({ root = process.cwd(), argv = [] } = {}) {
|
|
35
|
+
let resolveItem = false
|
|
36
|
+
const positionals = []
|
|
37
|
+
for (const token of argv) {
|
|
38
|
+
if (token === '--resolve') {
|
|
39
|
+
resolveItem = true
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
if (token.startsWith('--')) {
|
|
43
|
+
throw new Error(`unknown option: ${token}`)
|
|
44
|
+
}
|
|
45
|
+
positionals.push(token)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const [design, itemId, message] = positionals
|
|
49
|
+
if (!design || !itemId || !message || !message.trim()) {
|
|
50
|
+
throw new Error('reply requires <design> <itemId> "<message>" [--resolve]')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { file, review } = loadReviewForMutation(root, design)
|
|
54
|
+
const index = review.items.findIndex((entry) => entry?.id === itemId)
|
|
55
|
+
if (index === -1) {
|
|
56
|
+
throw new Error(`review item not found in ${design}: ${itemId}`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const now = new Date().toISOString()
|
|
60
|
+
const existing = review.items[index]
|
|
61
|
+
const reply = {
|
|
62
|
+
id: `reply-${crypto.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`}`,
|
|
63
|
+
author: 'agent',
|
|
64
|
+
body: message.trim(),
|
|
65
|
+
createdAt: now,
|
|
66
|
+
}
|
|
67
|
+
const thread = Array.isArray(existing.thread) ? [...existing.thread, reply] : [reply]
|
|
68
|
+
const updatedItem = {
|
|
69
|
+
...existing,
|
|
70
|
+
thread,
|
|
71
|
+
updatedAt: now,
|
|
72
|
+
...(resolveItem ? { status: 'resolved', resolvedAt: existing.resolvedAt ?? now } : {}),
|
|
73
|
+
}
|
|
74
|
+
const items = review.items.map((entry, idx) => (idx === index ? updatedItem : entry))
|
|
75
|
+
saveReviewMutation(file, { ...review, items }, now)
|
|
76
|
+
return { item: updatedItem, reply, file }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function updateReviewItemStatus({ root = process.cwd(), argv = [] } = {}) {
|
|
80
|
+
let agentReply
|
|
81
|
+
const positionals = []
|
|
82
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
83
|
+
const token = argv[i]
|
|
84
|
+
if (token === '--reply') {
|
|
85
|
+
const next = argv[i + 1]
|
|
86
|
+
if (next === undefined) throw new Error('--reply requires a summary string')
|
|
87
|
+
agentReply = next
|
|
88
|
+
i += 1
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
if (token.startsWith('--reply=')) {
|
|
92
|
+
agentReply = token.slice('--reply='.length)
|
|
93
|
+
continue
|
|
94
|
+
}
|
|
95
|
+
if (token.startsWith('--')) {
|
|
96
|
+
throw new Error(`unknown option: ${token}`)
|
|
97
|
+
}
|
|
98
|
+
positionals.push(token)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const [design, itemId, status] = positionals
|
|
102
|
+
if (!design || !itemId || !status) {
|
|
103
|
+
throw new Error('status requires <design> <itemId> <in_progress|resolved> [--reply "<summary>"]')
|
|
104
|
+
}
|
|
105
|
+
if (!VALID_STATUSES.has(status)) {
|
|
106
|
+
throw new Error(`Invalid status "${status}". Expected "in_progress" or "resolved".`)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const { file, review } = loadReviewForMutation(root, design)
|
|
110
|
+
const index = review.items.findIndex((entry) => entry?.id === itemId)
|
|
111
|
+
if (index === -1) {
|
|
112
|
+
throw new Error(`review item not found in ${design}: ${itemId}`)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const now = new Date().toISOString()
|
|
116
|
+
const existing = review.items[index]
|
|
117
|
+
const updatedItem = {
|
|
118
|
+
...existing,
|
|
119
|
+
status,
|
|
120
|
+
updatedAt: now,
|
|
121
|
+
...(status === 'resolved' ? { resolvedAt: now } : {}),
|
|
122
|
+
...(agentReply !== undefined ? { agentReply } : {}),
|
|
123
|
+
}
|
|
124
|
+
const items = review.items.map((entry, idx) => (idx === index ? updatedItem : entry))
|
|
125
|
+
saveReviewMutation(file, { ...review, items }, now)
|
|
126
|
+
return { item: updatedItem, file }
|
|
127
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReviewItem } from '../shared/types';
|
|
2
|
+
type Props = {
|
|
3
|
+
item: ReviewItem;
|
|
4
|
+
onApprove: (id: string, value: string, note: string) => void;
|
|
5
|
+
onReject: (id: string, note: string) => void;
|
|
6
|
+
onUpdateValue?: (id: string, value: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function AgentProposalCard({ item, onApprove, onReject, onUpdateValue }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AgentProposalCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentProposalCard.d.ts","sourceRoot":"","sources":["../../src/editor/AgentProposalCard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAIjD,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5D,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CACpD,CAAA;AAID,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,KAAK,+BAsGpF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useI18n } from './i18n';
|
|
4
|
+
import { Button } from './ui/Button';
|
|
5
|
+
const isHexColor = (value) => /^#[0-9a-f]{6}$/i.test(value.trim());
|
|
6
|
+
export function AgentProposalCard({ item, onApprove, onReject, onUpdateValue }) {
|
|
7
|
+
const { t } = useI18n();
|
|
8
|
+
const tokenName = item.target.type === 'token' ? item.target.token : '';
|
|
9
|
+
const [valueDraft, setValueDraft] = useState(String(item.to ?? ''));
|
|
10
|
+
const [noteDraft, setNoteDraft] = useState(item.decisionNote ?? '');
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setValueDraft(String(item.to ?? ''));
|
|
13
|
+
}, [item.to]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setNoteDraft(item.decisionNote ?? '');
|
|
16
|
+
}, [item.decisionNote]);
|
|
17
|
+
const tierKey = item.tokenTier === 'primitive' || item.tokenTier === 'component' ? item.tokenTier : 'semantic';
|
|
18
|
+
return (_jsxs("div", { className: "proposal-card", "data-proposal-id": item.id, children: [_jsxs("div", { className: "proposal-head", children: [_jsx("span", { className: "proposal-badge", children: t('proposal.badge') }), item.tokenAction ? (_jsx("span", { className: "change-action", children: t(`changes.tokenAction.${item.tokenAction}`) })) : null, _jsx("span", { className: "proposal-tier", children: t(`tokens.tier.${tierKey}`) })] }), _jsxs("div", { className: "proposal-token-row", children: [_jsx("code", { children: tokenName }), item.tokenAlias ? (_jsxs("span", { className: "proposal-alias", children: [t('proposal.aliasLabel'), ": ", _jsx("code", { children: `{${item.tokenAlias}}` })] })) : null] }), item.source ? _jsx("code", { className: "proposal-source", children: item.source }) : null, item.rationale ? (_jsxs("p", { className: "proposal-rationale", children: [_jsxs("strong", { children: [t('proposal.rationale'), ":"] }), " ", item.rationale] })) : null, _jsxs("div", { className: "proposal-controls", children: [_jsxs("label", { className: "proposal-field", children: [_jsx("span", { children: t('proposal.valueLabel') }), _jsxs("div", { className: "proposal-value-input", children: [item.tokenType === 'color' && isHexColor(valueDraft) ? (_jsx("input", { "aria-label": tokenName, className: "proposal-color-picker", type: "color", value: valueDraft.trim(), onChange: (event) => {
|
|
19
|
+
const next = event.target.value;
|
|
20
|
+
setValueDraft(next);
|
|
21
|
+
onUpdateValue?.(item.id, next);
|
|
22
|
+
} })) : null, _jsx("input", { className: "input", value: valueDraft, onChange: (event) => {
|
|
23
|
+
const next = event.target.value;
|
|
24
|
+
setValueDraft(next);
|
|
25
|
+
onUpdateValue?.(item.id, next);
|
|
26
|
+
} })] })] }), _jsxs("label", { className: "proposal-field", children: [_jsx("span", { children: t('proposal.noteLabel') }), _jsx("input", { className: "input", placeholder: t('proposal.notePlaceholder'), value: noteDraft, onChange: (event) => setNoteDraft(event.target.value) })] })] }), _jsxs("div", { className: "proposal-actions", children: [_jsx(Button, { className: "primary-button", type: "button", onClick: () => onApprove(item.id, valueDraft.trim() || String(item.to ?? ''), noteDraft), children: t('proposal.approve') }), _jsx(Button, { className: "button", type: "button", onClick: () => onReject(item.id, noteDraft), children: t('proposal.reject') })] })] }));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=AgentProposalCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentProposalCard.js","sourceRoot":"","sources":["../../src/editor/AgentProposalCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAG3C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AASpC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;AAE1E,MAAM,UAAU,iBAAiB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAS;IACnF,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAA;IACvB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IACvE,M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