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.
Files changed (98) hide show
  1. package/README.md +42 -17
  2. package/bin/agent-canvas.js +7 -7
  3. package/bin/agent-canvas.ts +48 -37
  4. package/bin/lib/commands/daemon.ts +46 -43
  5. package/bin/lib/commands/exec.ts +100 -100
  6. package/bin/lib/commands/fetch.ts +15 -15
  7. package/bin/lib/commands/install.ts +36 -36
  8. package/bin/lib/commands/instructions.ts +51 -51
  9. package/bin/lib/commands/push.ts +115 -97
  10. package/bin/lib/commands/review.ts +190 -0
  11. package/bin/lib/commands/watch.ts +24 -24
  12. package/bin/lib/config.ts +12 -12
  13. package/bin/lib/daemon-lifecycle.ts +47 -51
  14. package/bin/lib/helpers.ts +82 -76
  15. package/bin/lib/instructions/app-review.md +88 -0
  16. package/bin/lib/instructions/component-checklist.md +7 -5
  17. package/bin/lib/instructions/component-custom.md +20 -14
  18. package/bin/lib/instructions/component-diff.md +4 -3
  19. package/bin/lib/instructions/component-item.md +18 -8
  20. package/bin/lib/instructions/component-markdown.md +4 -2
  21. package/bin/lib/instructions/component-mermaid.md +12 -6
  22. package/bin/lib/instructions/component-multichoice.md +6 -2
  23. package/bin/lib/instructions/component-note.md +1 -1
  24. package/bin/lib/instructions/component-priority.md +1 -1
  25. package/bin/lib/instructions/component-rangeinput.md +9 -2
  26. package/bin/lib/instructions/component-secretinput.md +12 -11
  27. package/bin/lib/instructions/component-svg.md +62 -16
  28. package/bin/lib/instructions/component-table.md +6 -6
  29. package/bin/lib/instructions/component-usefeedback.md +8 -8
  30. package/bin/lib/instructions/component-userinput.md +6 -2
  31. package/bin/lib/instructions/flow-feature.md +22 -5
  32. package/bin/lib/instructions/flow-plan.md +5 -5
  33. package/bin/lib/instructions/flow-runbook.md +28 -25
  34. package/bin/lib/instructions/overview.md +27 -18
  35. package/bin/lib/instructions/theming.md +5 -0
  36. package/daemon/build.ts +171 -152
  37. package/daemon/client/App.tsx +1205 -1077
  38. package/daemon/client/CompareView.tsx +478 -458
  39. package/daemon/client/FileBrowser.tsx +241 -203
  40. package/daemon/client/FileViewer.tsx +220 -211
  41. package/daemon/client/OverviewView.tsx +283 -267
  42. package/daemon/client/ReviewerIdentityDialog.tsx +72 -71
  43. package/daemon/client/RevisionSelect.tsx +111 -95
  44. package/daemon/client/SessionSwitcher.tsx +81 -81
  45. package/daemon/client/ShareDialog.tsx +211 -212
  46. package/daemon/client/apiSchemas.ts +78 -0
  47. package/daemon/client/canvas-runtime.ts +1 -1
  48. package/daemon/client/clientApi.ts +194 -206
  49. package/daemon/client/components/SecretInput.tsx +138 -138
  50. package/daemon/client/components/index.ts +2 -2
  51. package/daemon/client/domDiff.ts +341 -333
  52. package/daemon/client/errorMessage.ts +3 -0
  53. package/daemon/client/exportMarkdown.ts +222 -201
  54. package/daemon/client/lcs.ts +19 -14
  55. package/daemon/client/shareCrypto.ts +57 -57
  56. package/daemon/client/unifiedDiff.ts +660 -649
  57. package/daemon/dist/annotations-runtime.js +1 -1
  58. package/daemon/dist/client.css +2 -2
  59. package/daemon/dist/client.js +77 -80
  60. package/daemon/dist/components.js +59 -59
  61. package/daemon/dist/preact-compat.js +1 -1
  62. package/daemon/dist/review.js +361 -0
  63. package/daemon/dist/runtime.js +1 -1
  64. package/daemon/langMap.ts +24 -6
  65. package/daemon/review-widget/anchor.ts +187 -0
  66. package/daemon/review-widget/client.ts +95 -0
  67. package/daemon/review-widget/index.tsx +36 -0
  68. package/daemon/review-widget/markup.ts +71 -0
  69. package/daemon/review-widget/screenshot.ts +91 -0
  70. package/daemon/review-widget/source.ts +103 -0
  71. package/daemon/review-widget/styles.css +359 -0
  72. package/daemon/review-widget/text-modules.d.ts +4 -0
  73. package/daemon/review-widget/tsconfig.json +16 -0
  74. package/daemon/review-widget/widget.tsx +436 -0
  75. package/daemon/src/components.ts +3 -3
  76. package/daemon/src/handlers/api.ts +330 -328
  77. package/daemon/src/handlers/files.ts +112 -105
  78. package/daemon/src/handlers/static.ts +47 -46
  79. package/daemon/src/handlers/uploads.ts +61 -56
  80. package/daemon/src/paths.ts +13 -10
  81. package/daemon/src/remote-feedback.ts +192 -192
  82. package/daemon/src/review/markdown.ts +52 -0
  83. package/daemon/src/review/model.ts +132 -0
  84. package/daemon/src/review/proxy.ts +177 -0
  85. package/daemon/src/review/server.ts +199 -0
  86. package/daemon/src/review/store.ts +151 -0
  87. package/daemon/src/server.ts +127 -86
  88. package/daemon/src/share.ts +163 -169
  89. package/daemon/src/stubFetch.ts +7 -0
  90. package/daemon/tsconfig.json +19 -19
  91. package/package.json +47 -47
  92. package/skills/canvas/SKILL.md +9 -1
  93. package/bin/lib/commands/exec.test.ts +0 -27
  94. package/bin/lib/helpers.test.ts +0 -79
  95. package/daemon/src/remote-feedback.test.ts +0 -165
  96. package/daemon/src/secrets-api.test.ts +0 -123
  97. package/daemon/src/share-e2e.test.ts +0 -277
  98. 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 = "AES-GCM" as const;
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
- alg: typeof CRYPTO_ALG;
26
- v: typeof CRYPTO_VERSION;
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
- return crypto.subtle.generateKey(
34
- { name: CRYPTO_ALG, length: 256 },
35
- true,
36
- ["encrypt", "decrypt"],
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
- const raw = await crypto.subtle.exportKey("raw", key);
43
- return b64urlFromBytes(new Uint8Array(raw));
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
- 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
- );
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
- 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);
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
- 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);
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
- return encryptString(key, JSON.stringify(value));
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
- return JSON.parse(await decryptString(key, ciphertext)) as T;
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
- 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);
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
- 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;
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
- return b64FromBytes(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
117
+ return b64FromBytes(bytes).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
118
118
  }
119
119
 
120
120
  function bytesFromB64url(s: string): Uint8Array {
121
- const padded = s.replace(/-/g, "+").replace(/_/g, "/") + "===".slice((s.length + 3) % 4);
122
- return bytesFromB64(padded);
121
+ const padded = s.replace(/-/g, '+').replace(/_/g, '/') + '==='.slice((s.length + 3) % 4)
122
+ return bytesFromB64(padded)
123
123
  }