@oked/claude-code 0.6.19 → 0.6.20
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/dist/cli.js +39 -3
- package/dist/qr.d.ts +7 -0
- package/dist/qr.js +332 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,7 @@ import { OKedClient, loadOKedConfig, OKED_CONFIG_PATH } from "@oked/sdk";
|
|
|
8
8
|
import { HOOK_CONFIG, hasOkedCommandHook, ensureMcpMatcher, ensureHookTimeout, upgradeSettingsFile, userSettingsPath, } from "./hook-config.js";
|
|
9
9
|
import { CLIENT_VERSION } from "./version.js";
|
|
10
10
|
import { OKED_RECEIPTS_LOG, verifyReceiptsFile } from "./receipts.js";
|
|
11
|
+
import { renderQR } from "./qr.js";
|
|
11
12
|
const DEFAULT_BACKEND_URL = process.env.OKED_BACKEND_URL || "https://api.oked.ai";
|
|
12
13
|
/** `oked init --key-only`: create or show the API key; add or change no hook. */
|
|
13
14
|
const KEY_ONLY = process.argv.includes("--key-only");
|
|
@@ -118,14 +119,27 @@ function copyToClipboard(text) {
|
|
|
118
119
|
return candidates.reduce((acc, cand) => acc.then((ok) => (ok ? true : tryCopy(cand))), Promise.resolve(false));
|
|
119
120
|
}
|
|
120
121
|
/** Wait for the user to press Enter. Resolves immediately if stdin is closed. */
|
|
122
|
+
/** Ask for Enter. cancel() takes the prompt away, for when pairing ends first. */
|
|
121
123
|
function waitForEnter(message) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
125
|
+
// The pairing poll keeps the process alive, so Ctrl+C must exit on purpose.
|
|
126
|
+
rl.on("SIGINT", () => {
|
|
127
|
+
process.stdout.write("\n");
|
|
128
|
+
process.exit(130);
|
|
129
|
+
});
|
|
130
|
+
const pressed = new Promise((resolve) => {
|
|
124
131
|
rl.question(message, () => {
|
|
125
132
|
rl.close();
|
|
126
133
|
resolve();
|
|
127
134
|
});
|
|
128
135
|
});
|
|
136
|
+
return {
|
|
137
|
+
pressed,
|
|
138
|
+
cancel: () => {
|
|
139
|
+
process.stdout.write("\n");
|
|
140
|
+
rl.close();
|
|
141
|
+
},
|
|
142
|
+
};
|
|
129
143
|
}
|
|
130
144
|
async function pair(clientType) {
|
|
131
145
|
const codeRes = await fetch(`${DEFAULT_BACKEND_URL}/api/v1/device/code`, {
|
|
@@ -151,6 +165,16 @@ async function pair(clientType) {
|
|
|
151
165
|
console.log(" (copied to clipboard)");
|
|
152
166
|
}
|
|
153
167
|
console.log("");
|
|
168
|
+
// The QR code holds the pairing link: the OKed app pairs from it, and the
|
|
169
|
+
// Camera app opens it in the browser. Only in a terminal that shows colors.
|
|
170
|
+
if (process.stdout.isTTY && !process.env.NO_COLOR) {
|
|
171
|
+
console.log(" Or scan this with your iPhone:");
|
|
172
|
+
console.log("");
|
|
173
|
+
console.log(renderQR(code.verification_uri_complete));
|
|
174
|
+
console.log("");
|
|
175
|
+
}
|
|
176
|
+
// Poll from now on, so a scan from the phone pairs before anyone presses Enter.
|
|
177
|
+
const paired = pollForKey(code);
|
|
154
178
|
// Let the user read the code and initiate the browser launch themselves, so
|
|
155
179
|
// the popup isn't a surprise. Skip the prompt when non-interactive (no TTY,
|
|
156
180
|
// or `--yes`/`-y`) so CI and scripted installs still work.
|
|
@@ -158,13 +182,21 @@ async function pair(clientType) {
|
|
|
158
182
|
!process.argv.includes("--yes") &&
|
|
159
183
|
!process.argv.includes("-y");
|
|
160
184
|
if (interactive && !NO_BROWSER) {
|
|
161
|
-
|
|
185
|
+
const enter = waitForEnter(" Press Enter to open your browser (Ctrl+C to cancel)... ");
|
|
186
|
+
const first = await Promise.race([enter.pressed.then(() => "enter"), paired.then(() => "paired")]);
|
|
187
|
+
if (first === "paired") {
|
|
188
|
+
enter.cancel();
|
|
189
|
+
return paired;
|
|
190
|
+
}
|
|
162
191
|
}
|
|
163
192
|
const opened = NO_BROWSER ? false : openBrowser(code.verification_uri_complete);
|
|
164
193
|
console.log("");
|
|
165
194
|
if (opened) {
|
|
166
195
|
console.log(" Opened your browser to:");
|
|
167
196
|
}
|
|
197
|
+
else if (NO_BROWSER) {
|
|
198
|
+
console.log(" Open this link:");
|
|
199
|
+
}
|
|
168
200
|
else {
|
|
169
201
|
console.log(" Couldn't open your browser automatically. Open this link:");
|
|
170
202
|
}
|
|
@@ -174,6 +206,10 @@ async function pair(clientType) {
|
|
|
174
206
|
console.log(" or enter it in the OKed app on your iPhone.)");
|
|
175
207
|
console.log("");
|
|
176
208
|
console.log(" Waiting for confirmation...");
|
|
209
|
+
return paired;
|
|
210
|
+
}
|
|
211
|
+
/** Poll until the code is confirmed (the API key), or it expires (null). */
|
|
212
|
+
async function pollForKey(code) {
|
|
177
213
|
const deadline = Date.now() + code.expires_in * 1000;
|
|
178
214
|
const intervalMs = Math.max(1, code.interval) * 1000;
|
|
179
215
|
while (Date.now() < deadline) {
|
package/dist/qr.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The QR modules for text: rows of booleans, true is dark. No quiet zone. */
|
|
2
|
+
export declare function encodeQR(text: string): boolean[][];
|
|
3
|
+
/**
|
|
4
|
+
* The QR code as terminal text, two modules per character with half blocks,
|
|
5
|
+
* in black on white with ANSI colors, so it scans on dark and light themes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderQR(text: string, indent?: string): string;
|
package/dist/qr.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// A small QR code encoder for the pairing link that `oked init` prints, so the
|
|
2
|
+
// OKed iPhone app can scan it. Byte mode, error correction level M, versions
|
|
3
|
+
// 1 to 10 (up to 213 bytes): enough for a URL. It follows ISO/IEC 18004 and
|
|
4
|
+
// Project Nayuki's reference design. It is here, not a dependency, so the hook
|
|
5
|
+
// package keeps a single dependency.
|
|
6
|
+
const ECC_PER_BLOCK = [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26];
|
|
7
|
+
const NUM_BLOCKS = [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5];
|
|
8
|
+
const MAX_VERSION = 10;
|
|
9
|
+
const FORMAT_ECC_M = 0;
|
|
10
|
+
/** The QR modules for text: rows of booleans, true is dark. No quiet zone. */
|
|
11
|
+
export function encodeQR(text) {
|
|
12
|
+
const bytes = [...Buffer.from(text, "utf8")];
|
|
13
|
+
let version = 1;
|
|
14
|
+
for (; version <= MAX_VERSION; version++) {
|
|
15
|
+
if (4 + charCountBits(version) + bytes.length * 8 <= dataCodewords(version) * 8)
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
if (version > MAX_VERSION)
|
|
19
|
+
throw new Error("Text too long for a QR code");
|
|
20
|
+
// The data bits: mode, length, bytes, terminator, then pad bytes.
|
|
21
|
+
const capacity = dataCodewords(version) * 8;
|
|
22
|
+
const bits = [];
|
|
23
|
+
const append = (value, length) => {
|
|
24
|
+
for (let i = length - 1; i >= 0; i--)
|
|
25
|
+
bits.push((value >>> i) & 1);
|
|
26
|
+
};
|
|
27
|
+
append(0b0100, 4);
|
|
28
|
+
append(bytes.length, charCountBits(version));
|
|
29
|
+
for (const b of bytes)
|
|
30
|
+
append(b, 8);
|
|
31
|
+
append(0, Math.min(4, capacity - bits.length));
|
|
32
|
+
append(0, (8 - (bits.length % 8)) % 8);
|
|
33
|
+
for (let pad = 0xec; bits.length < capacity; pad ^= 0xec ^ 0x11)
|
|
34
|
+
append(pad, 8);
|
|
35
|
+
const data = [];
|
|
36
|
+
for (let i = 0; i < bits.length; i += 8)
|
|
37
|
+
data.push(parseInt(bits.slice(i, i + 8).join(""), 2));
|
|
38
|
+
const qr = new Matrix(version);
|
|
39
|
+
qr.drawFunctionPatterns();
|
|
40
|
+
qr.drawCodewords(addEccAndInterleave(data, version));
|
|
41
|
+
let best = [];
|
|
42
|
+
let bestPenalty = Infinity;
|
|
43
|
+
for (let mask = 0; mask < 8; mask++) {
|
|
44
|
+
const masked = qr.withMask(mask);
|
|
45
|
+
const penalty = penaltyScore(masked);
|
|
46
|
+
if (penalty < bestPenalty) {
|
|
47
|
+
best = masked;
|
|
48
|
+
bestPenalty = penalty;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return best;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The QR code as terminal text, two modules per character with half blocks,
|
|
55
|
+
* in black on white with ANSI colors, so it scans on dark and light themes.
|
|
56
|
+
*/
|
|
57
|
+
export function renderQR(text, indent = " ") {
|
|
58
|
+
const modules = encodeQR(text);
|
|
59
|
+
const quiet = 2;
|
|
60
|
+
const size = modules.length + quiet * 2;
|
|
61
|
+
const dark = (x, y) => x >= quiet && y >= quiet && x < size - quiet && y < size - quiet && modules[y - quiet][x - quiet];
|
|
62
|
+
const lines = [];
|
|
63
|
+
for (let y = 0; y < size; y += 2) {
|
|
64
|
+
let line = "";
|
|
65
|
+
for (let x = 0; x < size; x++) {
|
|
66
|
+
const top = dark(x, y);
|
|
67
|
+
const bottom = y + 1 < size && dark(x, y + 1);
|
|
68
|
+
line += top && bottom ? "█" : top ? "▀" : bottom ? "▄" : " ";
|
|
69
|
+
}
|
|
70
|
+
lines.push(`${indent}\x1b[30;107m${line}\x1b[0m`);
|
|
71
|
+
}
|
|
72
|
+
return lines.join("\n");
|
|
73
|
+
}
|
|
74
|
+
function charCountBits(version) {
|
|
75
|
+
return version <= 9 ? 8 : 16;
|
|
76
|
+
}
|
|
77
|
+
function rawDataModules(version) {
|
|
78
|
+
let result = (16 * version + 128) * version + 64;
|
|
79
|
+
if (version >= 2) {
|
|
80
|
+
const numAlign = Math.floor(version / 7) + 2;
|
|
81
|
+
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
82
|
+
if (version >= 7)
|
|
83
|
+
result -= 36;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function dataCodewords(version) {
|
|
88
|
+
return Math.floor(rawDataModules(version) / 8) - ECC_PER_BLOCK[version] * NUM_BLOCKS[version];
|
|
89
|
+
}
|
|
90
|
+
function addEccAndInterleave(data, version) {
|
|
91
|
+
const numBlocks = NUM_BLOCKS[version];
|
|
92
|
+
const eccLen = ECC_PER_BLOCK[version];
|
|
93
|
+
const rawCodewords = Math.floor(rawDataModules(version) / 8);
|
|
94
|
+
const numShortBlocks = numBlocks - (rawCodewords % numBlocks);
|
|
95
|
+
const shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
|
96
|
+
const divisor = reedSolomonDivisor(eccLen);
|
|
97
|
+
const blocks = [];
|
|
98
|
+
for (let i = 0, k = 0; i < numBlocks; i++) {
|
|
99
|
+
const dat = data.slice(k, k + shortBlockLen - eccLen + (i < numShortBlocks ? 0 : 1));
|
|
100
|
+
k += dat.length;
|
|
101
|
+
const ecc = reedSolomonRemainder(dat, divisor);
|
|
102
|
+
if (i < numShortBlocks)
|
|
103
|
+
dat.push(0);
|
|
104
|
+
blocks.push(dat.concat(ecc));
|
|
105
|
+
}
|
|
106
|
+
const result = [];
|
|
107
|
+
for (let i = 0; i < blocks[0].length; i++) {
|
|
108
|
+
blocks.forEach((block, j) => {
|
|
109
|
+
// Skip the padding byte of the short blocks.
|
|
110
|
+
if (i !== shortBlockLen - eccLen || j >= numShortBlocks)
|
|
111
|
+
result.push(block[i]);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
function gfMultiply(x, y) {
|
|
117
|
+
let z = 0;
|
|
118
|
+
for (let i = 7; i >= 0; i--) {
|
|
119
|
+
z = (z << 1) ^ ((z >>> 7) * 0x11d);
|
|
120
|
+
z ^= ((y >>> i) & 1) * x;
|
|
121
|
+
}
|
|
122
|
+
return z;
|
|
123
|
+
}
|
|
124
|
+
function reedSolomonDivisor(degree) {
|
|
125
|
+
const result = new Array(degree).fill(0);
|
|
126
|
+
result[degree - 1] = 1;
|
|
127
|
+
let root = 1;
|
|
128
|
+
for (let i = 0; i < degree; i++) {
|
|
129
|
+
for (let j = 0; j < result.length; j++) {
|
|
130
|
+
result[j] = gfMultiply(result[j], root);
|
|
131
|
+
if (j + 1 < result.length)
|
|
132
|
+
result[j] ^= result[j + 1];
|
|
133
|
+
}
|
|
134
|
+
root = gfMultiply(root, 0x02);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
function reedSolomonRemainder(data, divisor) {
|
|
139
|
+
const result = divisor.map(() => 0);
|
|
140
|
+
for (const b of data) {
|
|
141
|
+
const factor = b ^ result.shift();
|
|
142
|
+
result.push(0);
|
|
143
|
+
divisor.forEach((coef, i) => (result[i] ^= gfMultiply(coef, factor)));
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
class Matrix {
|
|
148
|
+
version;
|
|
149
|
+
size;
|
|
150
|
+
modules;
|
|
151
|
+
isFunction;
|
|
152
|
+
constructor(version) {
|
|
153
|
+
this.version = version;
|
|
154
|
+
this.size = version * 4 + 17;
|
|
155
|
+
this.modules = Array.from({ length: this.size }, () => new Array(this.size).fill(false));
|
|
156
|
+
this.isFunction = Array.from({ length: this.size }, () => new Array(this.size).fill(false));
|
|
157
|
+
}
|
|
158
|
+
set(x, y, dark) {
|
|
159
|
+
this.modules[y][x] = dark;
|
|
160
|
+
this.isFunction[y][x] = true;
|
|
161
|
+
}
|
|
162
|
+
drawFunctionPatterns() {
|
|
163
|
+
const size = this.size;
|
|
164
|
+
for (let i = 0; i < size; i++) {
|
|
165
|
+
this.set(6, i, i % 2 === 0);
|
|
166
|
+
this.set(i, 6, i % 2 === 0);
|
|
167
|
+
}
|
|
168
|
+
this.drawFinder(3, 3);
|
|
169
|
+
this.drawFinder(size - 4, 3);
|
|
170
|
+
this.drawFinder(3, size - 4);
|
|
171
|
+
const positions = this.alignmentPositions();
|
|
172
|
+
const last = positions.length - 1;
|
|
173
|
+
positions.forEach((x, i) => positions.forEach((y, j) => {
|
|
174
|
+
if ((i === 0 && j === 0) || (i === 0 && j === last) || (i === last && j === 0))
|
|
175
|
+
return;
|
|
176
|
+
for (let dy = -2; dy <= 2; dy++) {
|
|
177
|
+
for (let dx = -2; dx <= 2; dx++)
|
|
178
|
+
this.set(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
// Reserve the format areas now; withMask() writes the real bits.
|
|
182
|
+
this.drawFormatBits(0, this.modules);
|
|
183
|
+
if (this.version >= 7) {
|
|
184
|
+
let rem = this.version;
|
|
185
|
+
for (let i = 0; i < 12; i++)
|
|
186
|
+
rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
|
|
187
|
+
const bits = (this.version << 12) | rem;
|
|
188
|
+
for (let i = 0; i < 18; i++) {
|
|
189
|
+
const dark = ((bits >>> i) & 1) !== 0;
|
|
190
|
+
const a = size - 11 + (i % 3);
|
|
191
|
+
const b = Math.floor(i / 3);
|
|
192
|
+
this.set(a, b, dark);
|
|
193
|
+
this.set(b, a, dark);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
drawFinder(cx, cy) {
|
|
198
|
+
for (let dy = -4; dy <= 4; dy++) {
|
|
199
|
+
for (let dx = -4; dx <= 4; dx++) {
|
|
200
|
+
const x = cx + dx;
|
|
201
|
+
const y = cy + dy;
|
|
202
|
+
const dist = Math.max(Math.abs(dx), Math.abs(dy));
|
|
203
|
+
if (x >= 0 && x < this.size && y >= 0 && y < this.size)
|
|
204
|
+
this.set(x, y, dist !== 2 && dist !== 4);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
alignmentPositions() {
|
|
209
|
+
if (this.version === 1)
|
|
210
|
+
return [];
|
|
211
|
+
const numAlign = Math.floor(this.version / 7) + 2;
|
|
212
|
+
const step = Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
|
|
213
|
+
const result = [6];
|
|
214
|
+
for (let pos = this.size - 7; result.length < numAlign; pos -= step)
|
|
215
|
+
result.splice(1, 0, pos);
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
drawFormatBits(mask, target) {
|
|
219
|
+
const data = (FORMAT_ECC_M << 3) | mask;
|
|
220
|
+
let rem = data;
|
|
221
|
+
for (let i = 0; i < 10; i++)
|
|
222
|
+
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
|
223
|
+
const bits = ((data << 10) | rem) ^ 0x5412;
|
|
224
|
+
const bit = (i) => ((bits >>> i) & 1) !== 0;
|
|
225
|
+
const put = (x, y, dark) => {
|
|
226
|
+
target[y][x] = dark;
|
|
227
|
+
this.isFunction[y][x] = true;
|
|
228
|
+
};
|
|
229
|
+
const size = this.size;
|
|
230
|
+
for (let i = 0; i <= 5; i++)
|
|
231
|
+
put(8, i, bit(i));
|
|
232
|
+
put(8, 7, bit(6));
|
|
233
|
+
put(8, 8, bit(7));
|
|
234
|
+
put(7, 8, bit(8));
|
|
235
|
+
for (let i = 9; i < 15; i++)
|
|
236
|
+
put(14 - i, 8, bit(i));
|
|
237
|
+
for (let i = 0; i < 8; i++)
|
|
238
|
+
put(size - 1 - i, 8, bit(i));
|
|
239
|
+
for (let i = 8; i < 15; i++)
|
|
240
|
+
put(8, size - 15 + i, bit(i));
|
|
241
|
+
put(8, size - 8, true);
|
|
242
|
+
}
|
|
243
|
+
drawCodewords(codewords) {
|
|
244
|
+
const size = this.size;
|
|
245
|
+
let i = 0;
|
|
246
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
247
|
+
if (right === 6)
|
|
248
|
+
right = 5;
|
|
249
|
+
for (let vert = 0; vert < size; vert++) {
|
|
250
|
+
for (let j = 0; j < 2; j++) {
|
|
251
|
+
const x = right - j;
|
|
252
|
+
const upward = ((right + 1) & 2) === 0;
|
|
253
|
+
const y = upward ? size - 1 - vert : vert;
|
|
254
|
+
if (!this.isFunction[y][x] && i < codewords.length * 8) {
|
|
255
|
+
this.modules[y][x] = ((codewords[i >>> 3] >>> (7 - (i & 7))) & 1) !== 0;
|
|
256
|
+
i++;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/** A copy with the data masked and the format bits for that mask. */
|
|
263
|
+
withMask(mask) {
|
|
264
|
+
const out = this.modules.map((row) => row.slice());
|
|
265
|
+
for (let y = 0; y < this.size; y++) {
|
|
266
|
+
for (let x = 0; x < this.size; x++) {
|
|
267
|
+
if (!this.isFunction[y][x] && maskBit(mask, x, y))
|
|
268
|
+
out[y][x] = !out[y][x];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
this.drawFormatBits(mask, out);
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function maskBit(mask, x, y) {
|
|
276
|
+
switch (mask) {
|
|
277
|
+
case 0: return (x + y) % 2 === 0;
|
|
278
|
+
case 1: return y % 2 === 0;
|
|
279
|
+
case 2: return x % 3 === 0;
|
|
280
|
+
case 3: return (x + y) % 3 === 0;
|
|
281
|
+
case 4: return (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
|
|
282
|
+
case 5: return ((x * y) % 2) + ((x * y) % 3) === 0;
|
|
283
|
+
case 6: return (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
284
|
+
default: return (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/** The standard mask penalty: runs, 2x2 blocks, finder-like patterns, balance. */
|
|
288
|
+
function penaltyScore(m) {
|
|
289
|
+
const size = m.length;
|
|
290
|
+
let score = 0;
|
|
291
|
+
const lines = [];
|
|
292
|
+
for (let i = 0; i < size; i++) {
|
|
293
|
+
lines.push(m[i]);
|
|
294
|
+
lines.push(m.map((row) => row[i]));
|
|
295
|
+
}
|
|
296
|
+
const finderLike = [
|
|
297
|
+
[true, false, true, true, true, false, true, false, false, false, false],
|
|
298
|
+
[false, false, false, false, true, false, true, true, true, false, true],
|
|
299
|
+
];
|
|
300
|
+
for (const line of lines) {
|
|
301
|
+
let run = 1;
|
|
302
|
+
for (let i = 1; i <= size; i++) {
|
|
303
|
+
if (i < size && line[i] === line[i - 1]) {
|
|
304
|
+
run++;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
if (run >= 5)
|
|
308
|
+
score += run - 2;
|
|
309
|
+
run = 1;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
for (let i = 0; i + 11 <= size; i++) {
|
|
313
|
+
for (const pattern of finderLike) {
|
|
314
|
+
if (pattern.every((v, k) => line[i + k] === v))
|
|
315
|
+
score += 40;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
let darkCount = 0;
|
|
320
|
+
for (let y = 0; y < size; y++) {
|
|
321
|
+
for (let x = 0; x < size; x++) {
|
|
322
|
+
if (m[y][x])
|
|
323
|
+
darkCount++;
|
|
324
|
+
if (x + 1 < size && y + 1 < size && m[y][x] === m[y][x + 1] && m[y][x] === m[y + 1][x] && m[y][x] === m[y + 1][x + 1]) {
|
|
325
|
+
score += 3;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const total = size * size;
|
|
330
|
+
score += Math.floor(Math.abs(darkCount * 20 - total * 10) / total) * 10;
|
|
331
|
+
return score;
|
|
332
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oked/claude-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.20",
|
|
4
4
|
"description": "OKed for Claude Code - zero-code human approval for sensitive actions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@oked/sdk": "0.6.
|
|
47
|
+
"@oked/sdk": "0.6.20"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"typescript": "^5.6.0"
|