@davait/aipictury 1.9.2

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 (54) hide show
  1. package/LICENSE.md +77 -0
  2. package/README.md +39 -0
  3. package/ext/about.js +209 -0
  4. package/ext/account.js +242 -0
  5. package/ext/accountUi.js +287 -0
  6. package/ext/agent.js +1929 -0
  7. package/ext/browser.js +263 -0
  8. package/ext/cloud.js +385 -0
  9. package/ext/context.js +241 -0
  10. package/ext/deps.js +142 -0
  11. package/ext/dialogs.js +803 -0
  12. package/ext/diff.js +150 -0
  13. package/ext/extension.js +2483 -0
  14. package/ext/feedback.js +55 -0
  15. package/ext/files.js +565 -0
  16. package/ext/firestore.js +131 -0
  17. package/ext/gpuRun.js +77 -0
  18. package/ext/gpuServer.js +76 -0
  19. package/ext/hooks.js +153 -0
  20. package/ext/log.js +29 -0
  21. package/ext/lsp.js +122 -0
  22. package/ext/mcp.js +469 -0
  23. package/ext/mcpAuth.js +128 -0
  24. package/ext/media/vendor/firebase-config.json +9 -0
  25. package/ext/media/vendor/signin.js +1 -0
  26. package/ext/mediagen.js +174 -0
  27. package/ext/memory.js +117 -0
  28. package/ext/notebook.js +82 -0
  29. package/ext/package.json +1234 -0
  30. package/ext/paths.js +50 -0
  31. package/ext/permissions.js +229 -0
  32. package/ext/plans.js +110 -0
  33. package/ext/plugins.js +243 -0
  34. package/ext/prefs.js +157 -0
  35. package/ext/remote.js +170 -0
  36. package/ext/review.js +126 -0
  37. package/ext/sandbox.js +79 -0
  38. package/ext/scheduler.js +87 -0
  39. package/ext/sessions.js +228 -0
  40. package/ext/sessionsView.js +449 -0
  41. package/ext/shell.js +357 -0
  42. package/ext/storage.js +80 -0
  43. package/ext/tasklist.js +112 -0
  44. package/ext/text.js +31 -0
  45. package/ext/tools.js +781 -0
  46. package/ext/usage.js +77 -0
  47. package/ext/voice.js +135 -0
  48. package/ext/workbench.js +162 -0
  49. package/ext/workflow.js +51 -0
  50. package/ext/worktree.js +83 -0
  51. package/main.js +758 -0
  52. package/package.json +43 -0
  53. package/terminal.js +124 -0
  54. package/vscode-shim.js +231 -0
package/ext/diff.js ADDED
@@ -0,0 +1,150 @@
1
+ 'use strict'
2
+ // A line diff for showing what the agent changed in a file, in the panel.
3
+ //
4
+ // Edits are usually local, so the common head and tail are trimmed first; the middle
5
+ // that is left is compared with a longest-common-subsequence table. A middle too large
6
+ // for that table is shown as removed-then-added, which is still correct, only coarser.
7
+
8
+ const CONTEXT = 3 // unchanged lines shown around each change
9
+ const MAX_TABLE = 4_000_000 // cells in the comparison table before falling back
10
+ const MAX_LINES = 400 // lines shown per diff in the panel
11
+
12
+ function splitLines(text) {
13
+ const lines = String(text ?? '').split('\n')
14
+ if (lines.length && lines[lines.length - 1] === '') lines.pop()
15
+ return lines
16
+ }
17
+
18
+ /** The edit script between two texts: [{ op: ' ' | '-' | '+', text, a, b }] where a and b
19
+ * are the 1-based line numbers in the old and new text. */
20
+ function lineDiff(before, after) {
21
+ const a = splitLines(before)
22
+ const b = splitLines(after)
23
+ let head = 0
24
+ while (head < a.length && head < b.length && a[head] === b[head]) head += 1
25
+ let tail = 0
26
+ while (tail < a.length - head && tail < b.length - head
27
+ && a[a.length - 1 - tail] === b[b.length - 1 - tail]) tail += 1
28
+
29
+ const midA = a.slice(head, a.length - tail)
30
+ const midB = b.slice(head, b.length - tail)
31
+ const out = []
32
+ for (let i = 0; i < head; i += 1) out.push({ op: ' ', text: a[i], a: i + 1, b: i + 1 })
33
+
34
+ if (midA.length * midB.length <= MAX_TABLE) {
35
+ // lcs[i][j] = length of the common subsequence of midA[i..] and midB[j..]
36
+ const n = midA.length
37
+ const m = midB.length
38
+ const lcs = Array.from({ length: n + 1 }, () => new Uint32Array(m + 1))
39
+ for (let i = n - 1; i >= 0; i -= 1) {
40
+ for (let j = m - 1; j >= 0; j -= 1) {
41
+ lcs[i][j] = midA[i] === midB[j] ? lcs[i + 1][j + 1] + 1 : Math.max(lcs[i + 1][j], lcs[i][j + 1])
42
+ }
43
+ }
44
+ let i = 0
45
+ let j = 0
46
+ while (i < n || j < m) {
47
+ if (i < n && j < m && midA[i] === midB[j]) {
48
+ out.push({ op: ' ', text: midA[i], a: head + i + 1, b: head + j + 1 }); i += 1; j += 1
49
+ } else if (i < n && (j === m || lcs[i + 1][j] >= lcs[i][j + 1])) {
50
+ // Removals before additions, the way diffs are read.
51
+ out.push({ op: '-', text: midA[i], a: head + i + 1 }); i += 1
52
+ } else {
53
+ out.push({ op: '+', text: midB[j], b: head + j + 1 }); j += 1
54
+ }
55
+ }
56
+ } else {
57
+ midA.forEach((text, i) => out.push({ op: '-', text, a: head + i + 1 }))
58
+ midB.forEach((text, j) => out.push({ op: '+', text, b: head + j + 1 }))
59
+ }
60
+
61
+ for (let k = 0; k < tail; k += 1) {
62
+ const ai = a.length - tail + k
63
+ const bi = b.length - tail + k
64
+ out.push({ op: ' ', text: a[ai], a: ai + 1, b: bi + 1 })
65
+ }
66
+ return out
67
+ }
68
+
69
+ /** What the panel draws: only the changed lines and a little context around them,
70
+ * with "…" rows where unchanged stretches were skipped. */
71
+ function summarize(before, after) {
72
+ const script = lineDiff(before, after)
73
+ const added = script.filter((l) => l.op === '+').length
74
+ const removed = script.filter((l) => l.op === '-').length
75
+ const keep = new Array(script.length).fill(false)
76
+ script.forEach((l, i) => {
77
+ if (l.op === ' ') return
78
+ for (let k = Math.max(0, i - CONTEXT); k <= Math.min(script.length - 1, i + CONTEXT); k += 1) keep[k] = true
79
+ })
80
+ const lines = []
81
+ let skipped = false
82
+ script.forEach((l, i) => {
83
+ if (keep[i]) {
84
+ if (skipped) lines.push({ op: '…' })
85
+ skipped = false
86
+ lines.push({ op: l.op, text: l.text.slice(0, 400), a: l.a, b: l.b })
87
+ } else {
88
+ skipped = true
89
+ }
90
+ })
91
+ const truncated = lines.length > MAX_LINES
92
+ return { added, removed, created: before === null, lines: lines.slice(0, MAX_LINES), truncated }
93
+ }
94
+
95
+ /** The changes between two texts as hunks — runs of changed lines — each with its lines,
96
+ * for a review that accepts or rejects them one at a time. */
97
+ function hunks(before, after) {
98
+ const script = lineDiff(before, after)
99
+ const out = []
100
+ let current = null
101
+ script.forEach((l, i) => {
102
+ if (l.op === ' ') { current = null; return }
103
+ if (!current) { current = { index: out.length, from: i, removed: [], added: [], line: l.a || l.b }; out.push(current) }
104
+ if (l.op === '-') current.removed.push(l.text); else current.added.push(l.text)
105
+ current.to = i
106
+ })
107
+ return out
108
+ }
109
+
110
+ /** `after`, with only the hunks in `keep` applied to `before` — the rest left as they were. */
111
+ function applyHunks(before, after, keep) {
112
+ const script = lineDiff(before, after)
113
+ const lines = []
114
+ let hunk = -1
115
+ let inHunk = false
116
+ for (const l of script) {
117
+ if (l.op === ' ') { inHunk = false; lines.push(l.text); continue }
118
+ if (!inHunk) { hunk += 1; inHunk = true }
119
+ const kept = keep.has(hunk)
120
+ if ((l.op === '+' && kept) || (l.op === '-' && !kept)) lines.push(l.text)
121
+ }
122
+ const endsWithNewline = /\n$/.test(keep.size ? after : before) || /\n$/.test(before)
123
+ return lines.join('\n') + (lines.length && endsWithNewline ? '\n' : '')
124
+ }
125
+
126
+ /** Where each hunk sits in `after`: { index, start, end } as 0-based line numbers (end is
127
+ * start - 1 for a hunk that only removes lines — it sits before line `start`). */
128
+ function hunkRanges(before, after) {
129
+ const script = lineDiff(before, after)
130
+ const out = []
131
+ let current = null
132
+ for (const l of script) {
133
+ if (l.op === ' ') {
134
+ if (current && current.start === undefined) { current.start = l.b - 1; current.end = l.b - 2 }
135
+ current = null
136
+ continue
137
+ }
138
+ if (!current) { current = { index: out.length }; out.push(current) }
139
+ if (l.op === '+') {
140
+ if (current.start === undefined) current.start = l.b - 1
141
+ current.end = l.b - 1
142
+ }
143
+ }
144
+ // A removal at the very end sits after the last line.
145
+ const lines = splitLines(after).length
146
+ for (const h of out) if (h.start === undefined) { h.start = lines; h.end = lines - 1 }
147
+ return out
148
+ }
149
+
150
+ module.exports = { lineDiff, summarize, splitLines, hunks, applyHunks, hunkRanges }