agent-canvas 0.2.0 → 0.6.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/README.md +42 -17
- package/bin/agent-canvas.js +7 -7
- package/bin/agent-canvas.ts +48 -37
- package/bin/lib/commands/daemon.ts +46 -43
- package/bin/lib/commands/exec.ts +100 -100
- package/bin/lib/commands/fetch.ts +15 -15
- package/bin/lib/commands/install.ts +36 -36
- package/bin/lib/commands/instructions.ts +51 -51
- package/bin/lib/commands/push.ts +115 -97
- package/bin/lib/commands/review.ts +190 -0
- package/bin/lib/commands/watch.ts +24 -24
- package/bin/lib/config.ts +12 -12
- package/bin/lib/daemon-lifecycle.ts +47 -51
- package/bin/lib/helpers.ts +82 -76
- package/bin/lib/instructions/app-review.md +88 -0
- package/bin/lib/instructions/component-checklist.md +7 -5
- package/bin/lib/instructions/component-custom.md +20 -14
- package/bin/lib/instructions/component-diff.md +4 -3
- package/bin/lib/instructions/component-item.md +18 -8
- package/bin/lib/instructions/component-markdown.md +4 -2
- package/bin/lib/instructions/component-mermaid.md +12 -6
- package/bin/lib/instructions/component-multichoice.md +6 -2
- package/bin/lib/instructions/component-note.md +1 -1
- package/bin/lib/instructions/component-priority.md +1 -1
- package/bin/lib/instructions/component-rangeinput.md +9 -2
- package/bin/lib/instructions/component-secretinput.md +12 -11
- package/bin/lib/instructions/component-svg.md +62 -16
- package/bin/lib/instructions/component-table.md +6 -6
- package/bin/lib/instructions/component-usefeedback.md +8 -8
- package/bin/lib/instructions/component-userinput.md +6 -2
- package/bin/lib/instructions/flow-feature.md +22 -5
- package/bin/lib/instructions/flow-plan.md +5 -5
- package/bin/lib/instructions/flow-runbook.md +28 -25
- package/bin/lib/instructions/overview.md +27 -18
- package/bin/lib/instructions/theming.md +5 -0
- package/daemon/build.ts +171 -152
- package/daemon/client/App.tsx +1205 -1077
- package/daemon/client/CompareView.tsx +478 -458
- package/daemon/client/FileBrowser.tsx +241 -203
- package/daemon/client/FileViewer.tsx +220 -211
- package/daemon/client/OverviewView.tsx +283 -267
- package/daemon/client/ReviewerIdentityDialog.tsx +72 -71
- package/daemon/client/RevisionSelect.tsx +111 -95
- package/daemon/client/SessionSwitcher.tsx +81 -81
- package/daemon/client/ShareDialog.tsx +211 -212
- package/daemon/client/apiSchemas.ts +78 -0
- package/daemon/client/canvas-runtime.ts +1 -1
- package/daemon/client/clientApi.ts +194 -206
- package/daemon/client/components/SecretInput.tsx +138 -138
- package/daemon/client/components/index.ts +2 -2
- package/daemon/client/domDiff.ts +341 -333
- package/daemon/client/errorMessage.ts +3 -0
- package/daemon/client/exportMarkdown.ts +222 -201
- package/daemon/client/lcs.ts +19 -14
- package/daemon/client/shareCrypto.ts +57 -57
- package/daemon/client/unifiedDiff.ts +660 -649
- package/daemon/dist/annotations-runtime.js +1 -1
- package/daemon/dist/client.css +2 -2
- package/daemon/dist/client.js +77 -80
- package/daemon/dist/components.js +59 -59
- package/daemon/dist/preact-compat.js +1 -1
- package/daemon/dist/review.js +361 -0
- package/daemon/dist/runtime.js +1 -1
- package/daemon/langMap.ts +24 -6
- package/daemon/review-widget/anchor.ts +187 -0
- package/daemon/review-widget/client.ts +95 -0
- package/daemon/review-widget/index.tsx +36 -0
- package/daemon/review-widget/markup.ts +71 -0
- package/daemon/review-widget/screenshot.ts +91 -0
- package/daemon/review-widget/source.ts +103 -0
- package/daemon/review-widget/styles.css +359 -0
- package/daemon/review-widget/text-modules.d.ts +4 -0
- package/daemon/review-widget/tsconfig.json +16 -0
- package/daemon/review-widget/widget.tsx +436 -0
- package/daemon/src/components.ts +3 -3
- package/daemon/src/handlers/api.ts +330 -328
- package/daemon/src/handlers/files.ts +112 -105
- package/daemon/src/handlers/static.ts +47 -46
- package/daemon/src/handlers/uploads.ts +61 -56
- package/daemon/src/paths.ts +13 -10
- package/daemon/src/remote-feedback.ts +192 -192
- package/daemon/src/review/markdown.ts +52 -0
- package/daemon/src/review/model.ts +132 -0
- package/daemon/src/review/proxy.ts +177 -0
- package/daemon/src/review/server.ts +199 -0
- package/daemon/src/review/store.ts +151 -0
- package/daemon/src/server.ts +127 -86
- package/daemon/src/share.ts +163 -169
- package/daemon/src/stubFetch.ts +7 -0
- package/daemon/tsconfig.json +19 -19
- package/package.json +47 -47
- package/skills/canvas/SKILL.md +9 -1
- package/bin/lib/commands/exec.test.ts +0 -27
- package/bin/lib/helpers.test.ts +0 -79
- package/daemon/src/remote-feedback.test.ts +0 -165
- package/daemon/src/secrets-api.test.ts +0 -123
- package/daemon/src/share-e2e.test.ts +0 -277
- package/daemon/src/share.test.ts +0 -289
|
@@ -18,106 +18,106 @@
|
|
|
18
18
|
* the marked fields contain ciphertext rather than plaintext.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
export const CRYPTO_ALG =
|
|
22
|
-
export const CRYPTO_VERSION = 1 as const
|
|
21
|
+
export const CRYPTO_ALG = 'AES-GCM' as const
|
|
22
|
+
export const CRYPTO_VERSION = 1 as const
|
|
23
23
|
|
|
24
24
|
export interface EncryptionMeta {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
alg: typeof CRYPTO_ALG
|
|
26
|
+
v: typeof CRYPTO_VERSION
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const ENCRYPTION_META: EncryptionMeta = { alg: CRYPTO_ALG, v: CRYPTO_VERSION }
|
|
29
|
+
export const ENCRYPTION_META: EncryptionMeta = { alg: CRYPTO_ALG, v: CRYPTO_VERSION }
|
|
30
30
|
|
|
31
31
|
/** Generate a fresh 256-bit AES-GCM key. */
|
|
32
32
|
export async function generateShareKey(): Promise<CryptoKey> {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return crypto.subtle.generateKey(
|
|
34
|
+
{ name: CRYPTO_ALG, length: 256 },
|
|
35
|
+
true,
|
|
36
|
+
['encrypt', 'decrypt'],
|
|
37
|
+
)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** Export a CryptoKey to a base64url string suitable for URL fragments. */
|
|
41
41
|
export async function exportShareKey(key: CryptoKey): Promise<string> {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const raw = await crypto.subtle.exportKey('raw', key)
|
|
43
|
+
return b64urlFromBytes(new Uint8Array(raw))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/** Import a base64url-encoded key for AES-GCM. */
|
|
47
47
|
export async function importShareKey(encoded: string): Promise<CryptoKey> {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const raw = bytesFromB64url(encoded)
|
|
49
|
+
return crypto.subtle.importKey(
|
|
50
|
+
'raw',
|
|
51
|
+
raw as BufferSource,
|
|
52
|
+
{ name: CRYPTO_ALG, length: 256 },
|
|
53
|
+
false,
|
|
54
|
+
['encrypt', 'decrypt'],
|
|
55
|
+
)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** Encrypt a UTF-8 string. Returns base64(IV || ciphertext+tag). */
|
|
59
59
|
export async function encryptString(key: CryptoKey, plaintext: string): Promise<string> {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
const iv = crypto.getRandomValues(new Uint8Array(12))
|
|
61
|
+
const data = new TextEncoder().encode(plaintext)
|
|
62
|
+
const ct = await crypto.subtle.encrypt(
|
|
63
|
+
{ name: CRYPTO_ALG, iv: iv as BufferSource },
|
|
64
|
+
key,
|
|
65
|
+
data as BufferSource,
|
|
66
|
+
)
|
|
67
|
+
const combined = new Uint8Array(iv.byteLength + ct.byteLength)
|
|
68
|
+
combined.set(iv, 0)
|
|
69
|
+
combined.set(new Uint8Array(ct), iv.byteLength)
|
|
70
|
+
return b64FromBytes(combined)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** Decrypt a base64-encoded ciphertext back to a UTF-8 string. */
|
|
74
74
|
export async function decryptString(key: CryptoKey, ciphertext: string): Promise<string> {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
const combined = bytesFromB64(ciphertext)
|
|
76
|
+
if (combined.byteLength < 12 + 16) throw new Error('Ciphertext too short')
|
|
77
|
+
const iv = combined.subarray(0, 12)
|
|
78
|
+
const ct = combined.subarray(12)
|
|
79
|
+
const pt = await crypto.subtle.decrypt(
|
|
80
|
+
{ name: CRYPTO_ALG, iv: iv as BufferSource },
|
|
81
|
+
key,
|
|
82
|
+
ct as BufferSource,
|
|
83
|
+
)
|
|
84
|
+
return new TextDecoder().decode(pt)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/** Convenience: encrypt a JSON-serializable value as a single ciphertext blob. */
|
|
88
88
|
export async function encryptJson(key: CryptoKey, value: unknown): Promise<string> {
|
|
89
|
-
|
|
89
|
+
return encryptString(key, JSON.stringify(value))
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/** Convenience: decrypt a ciphertext blob into a JSON value. */
|
|
93
93
|
export async function decryptJson<T = unknown>(key: CryptoKey, ciphertext: string): Promise<T> {
|
|
94
|
-
|
|
94
|
+
return JSON.parse(await decryptString(key, ciphertext)) as T
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// --- base64 helpers ---------------------------------------------------------
|
|
98
98
|
|
|
99
99
|
function b64FromBytes(bytes: Uint8Array): string {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
let bin = ''
|
|
101
|
+
// Chunk to avoid stack overflow on large inputs.
|
|
102
|
+
const CHUNK = 0x8000
|
|
103
|
+
for (let i = 0; i < bytes.byteLength; i += CHUNK) {
|
|
104
|
+
bin += String.fromCharCode.apply(null, Array.from(bytes.subarray(i, i + CHUNK)))
|
|
105
|
+
}
|
|
106
|
+
return btoa(bin)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
function bytesFromB64(s: string): Uint8Array {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
const bin = atob(s)
|
|
111
|
+
const out = new Uint8Array(bin.length)
|
|
112
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i)
|
|
113
|
+
return out
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
function b64urlFromBytes(bytes: Uint8Array): string {
|
|
117
|
-
|
|
117
|
+
return b64FromBytes(bytes).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function bytesFromB64url(s: string): Uint8Array {
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
const padded = s.replace(/-/g, '+').replace(/_/g, '/') + '==='.slice((s.length + 3) % 4)
|
|
122
|
+
return bytesFromB64(padded)
|
|
123
123
|
}
|