@akanjs/cli 3.1.0-rc.2 → 3.1.0-rc.21
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/.build-stamp +1 -1
- package/{CodeAgent-q50k4s45.js → CodeAgent-gzfc5t52.js} +2 -2
- package/{CodeAgentRpcHost-p7h6n2hp.js → CodeAgentRpcHost-9g27hmer.js} +1 -1
- package/{CodeTui-62g35ztk.js → CodeTui-bpsjs8wz.js} +47 -4
- package/TunnelShare-tfrnftgr.js +14 -0
- package/{agent.command-adfd5299.js → agent.command-67ysh3n6.js} +5 -5
- package/akanCode.js +7 -5
- package/{application.command-hj3gv1rx.js → application.command-q0tqw5pc.js} +38 -11
- package/{applicationBuildRunner-by10r9gf.js → applicationBuildRunner-wsszr305.js} +16 -9
- package/buildBatch.proc.js +7 -7
- package/{cloud.command-k2fhaape.js → cloud.command-e7tkxyx6.js} +17 -16
- package/cloud.script-krzh3d7k.js +24 -0
- package/{code.command-kt5zgcc2.js → code.command-ttk8tje2.js} +25 -12
- package/commandManifest.json +1 -1
- package/{context.command-8fgn42jw.js → context.command-bdsk2z2r.js} +17 -16
- package/context.runner-bxzv0gm0.js +25 -0
- package/{dependencyScanner-06z2dmrr.js → dependencyScanner-3afj2vt1.js} +1 -1
- package/{guideline.command-3yxxr2mm.js → guideline.command-man90n70.js} +2 -2
- package/guidelines/agentRule/agentRule.instruction.md +25 -10
- package/guidelines/conventions/conventions.instruction.md +486 -1084
- package/guidelines/cssRule/cssRule.instruction.md +16 -1
- package/guidelines/fieldRule/fieldRule.instruction.md +74 -0
- package/guidelines/framework/framework.instruction.md +4 -7
- package/guidelines/mcpRule/mcpRule.instruction.md +16 -9
- package/guidelines/modelConstant/modelConstant.instruction.md +2 -1
- package/guidelines/modelStore/modelStore.instruction.md +16 -0
- package/guidelines/pageRule/pageRule.instruction.md +80 -0
- package/guidelines/queryRule/queryRule.instruction.md +47 -12
- package/guidelines/runtimeRule/runtimeRule.instruction.md +89 -2
- package/guidelines/ssrRule/ssrRule.instruction.md +13 -0
- package/guidelines/transportRule/transportRule.instruction.md +107 -8
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +4 -4
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +70 -7
- package/incrementalBuilder.proc.js +4 -4
- package/{index-rhbabmja.js → index-033wne2j.js} +260 -259
- package/{index-xpdgxsj5.js → index-1r5a8bzx.js} +2216 -2216
- package/{index-jwqtchha.js → index-27y8t17p.js} +1 -1
- package/{index-wa5jbxj1.js → index-2mrn1mrg.js} +1 -0
- package/{index-t7nws9mx.js → index-2w8j2fnv.js} +661 -448
- package/{index-0909wckt.js → index-35m6bzm7.js} +238 -236
- package/{index-sqfdmb5b.js → index-4393nb4b.js} +4 -4
- package/{index-sby8fe1p.js → index-48edp6q4.js} +1 -1
- package/{index-g0vwzy9m.js → index-4v43h00g.js} +20 -21
- package/{index-azh29dc8.js → index-54wc2phm.js} +19 -14
- package/{index-k9rrten6.js → index-5nd1wtkv.js} +92 -94
- package/index-62md4dwy.js +260 -0
- package/{index-hnby7p9n.js → index-75n5q4ph.js} +7 -7
- package/{index-fjsv10hd.js → index-844q7f8z.js} +7 -7
- package/{index-tv8fjaba.js → index-8jehkey8.js} +4 -4
- package/{index-bea2gwc6.js → index-9mt4smfy.js} +2 -2
- package/{index-d2242ksy.js → index-at7bz0xq.js} +3 -0
- package/{index-3hx1z96c.js → index-bqbf654f.js} +1 -1
- package/{index-8zdwpxef.js → index-cae9m5jz.js} +119 -81
- package/{index-tz5evhdr.js → index-ebarbgba.js} +6 -6
- package/{index-2etqq75t.js → index-g6ax17x4.js} +1114 -1082
- package/{index-h85cxfkg.js → index-g9ks2k8c.js} +2 -2
- package/{index-nq045px5.js → index-h3r3nr9y.js} +356 -307
- package/{index-20cebtth.js → index-h6czey01.js} +79 -24
- package/{index-6726qr1m.js → index-jrmzcp66.js} +57 -58
- package/{index-q958tqqg.js → index-m9jj544v.js} +1 -1
- package/{index-8935h3n1.js → index-mdjc93e1.js} +1 -1
- package/{index-rk9sdys3.js → index-nv79n88g.js} +5 -5
- package/{index-kc8z134d.js → index-nx64dz92.js} +38 -15
- package/{index-z507nzhg.js → index-p2r64bpa.js} +4 -4
- package/{index-nq2ja5e0.js → index-pg1t468s.js} +3 -3
- package/{index-3reaaa1h.js → index-rc51f9ht.js} +29 -27
- package/{index-e9prnmyt.js → index-ta1dychm.js} +3 -3
- package/{index-2ahj896a.js → index-tvehn2sp.js} +1 -1
- package/{index-31ce9vhg.js → index-vkb9m4z7.js} +80 -38
- package/{index-58vvz603.js → index-xsd96yzw.js} +1 -1
- package/{index-pyxn1b53.js → index-zv5s8x58.js} +13 -13
- package/index.js +22 -22
- package/{library.command-8tw59xzj.js → library.command-6amzsrb8.js} +3 -3
- package/{localRegistry.command-tf3dmznd.js → localRegistry.command-yqc0nyhh.js} +15 -14
- package/{module.command-9vm8hffy.js → module.command-10x6jv6c.js} +5 -5
- package/{package.command-erbxe2tz.js → package.command-pwfvecjf.js} +4 -4
- package/package.json +21 -21
- package/{page.command-jpavcj0p.js → page.command-ahhgx9y1.js} +3 -3
- package/{pipeline.command-b8rzvjvv.js → pipeline.command-1ptr3e9y.js} +3 -3
- package/{primitive.command-sm32chzk.js → primitive.command-g5xwv6tj.js} +6 -6
- package/{projectTypecheck-jamtx95x.js → projectTypecheck-fx8x7cat.js} +1 -1
- package/{quality.command-pkd17n6y.js → quality.command-fw9ck061.js} +4 -4
- package/{repair.command-8y4mq6hs.js → repair.command-g8kecj96.js} +5 -5
- package/{scalar.command-q8khmyx5.js → scalar.command-fprap51w.js} +4 -4
- package/skills/akan-code/SKILL.md +4 -0
- package/skills/akan-store/SKILL.md +2 -1
- package/{subspace.command-51n0ykbx.js → subspace.command-sc0t527y.js} +11 -10
- package/templates/appSample/lib/task/Task.Util.tsx +7 -7
- package/templates/appSample/lib/task/Task.Zone.tsx +1 -1
- package/templates/appSample/ui/QuantityControl.tsx +2 -2
- package/templates/crudSinglePage/page.tsx +1 -1
- package/templates/lib/cnst.ts +0 -1
- package/templates/migration/__migrationId__.ts +23 -0
- package/templates/server.ts +8 -1
- package/templates/workspaceRoot/.gitignore.template +23 -52
- package/templates/workspaceRoot/biome.json.template +1 -1
- package/{tunnel.command-7820vtxq.js → tunnel.command-mqnsqbwf.js} +8 -7
- package/{workflow.command-n5sv4wqz.js → workflow.command-j0jgkr13.js} +10 -10
- package/{workspace.command-zdy60jh8.js → workspace.command-1r9hvvw0.js} +29 -28
- package/TunnelShare-f1egrktx.js +0 -13
- package/cloud.script-z8p5dz7e.js +0 -23
- package/context.runner-hnh0rg7m.js +0 -24
- package/index-n68jx79w.js +0 -120
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// pkgs/@akanjs/devkit/frontendBuild/cssBlockParser.ts
|
|
3
|
+
class CssBlockParser {
|
|
4
|
+
#css;
|
|
5
|
+
#stack = [{ kind: "block", prelude: "", atRule: null, nodes: [] }];
|
|
6
|
+
#pendingParts = [];
|
|
7
|
+
#segmentStart = 0;
|
|
8
|
+
#parenDepth = 0;
|
|
9
|
+
constructor(css) {
|
|
10
|
+
this.#css = css;
|
|
11
|
+
}
|
|
12
|
+
static parse(css) {
|
|
13
|
+
return new CssBlockParser(css).#run();
|
|
14
|
+
}
|
|
15
|
+
static walk(root, context, visit) {
|
|
16
|
+
const stack = [{ nodes: root.nodes, idx: 0, context }];
|
|
17
|
+
while (stack.length > 0) {
|
|
18
|
+
const frame = stack[stack.length - 1];
|
|
19
|
+
const node = frame.nodes[frame.idx];
|
|
20
|
+
if (!node) {
|
|
21
|
+
stack.pop();
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
frame.idx += 1;
|
|
25
|
+
const childContext = visit(node, frame.context);
|
|
26
|
+
if (node.kind === "block" && childContext !== null)
|
|
27
|
+
stack.push({ nodes: node.nodes, idx: 0, context: childContext });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
#run() {
|
|
31
|
+
const css = this.#css;
|
|
32
|
+
let idx = 0;
|
|
33
|
+
while (idx < css.length) {
|
|
34
|
+
const char = css[idx];
|
|
35
|
+
if (char === "/" && css[idx + 1] === "*") {
|
|
36
|
+
this.#pendingParts.push(css.slice(this.#segmentStart, idx));
|
|
37
|
+
const end = css.indexOf("*/", idx + 2);
|
|
38
|
+
idx = end === -1 ? css.length : end + 2;
|
|
39
|
+
this.#segmentStart = idx;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === "\\") {
|
|
43
|
+
idx += 2;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (char === '"' || char === "'") {
|
|
47
|
+
idx = this.#skipString(idx);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (char === "(")
|
|
51
|
+
this.#parenDepth += 1;
|
|
52
|
+
else if (char === ")")
|
|
53
|
+
this.#parenDepth = Math.max(0, this.#parenDepth - 1);
|
|
54
|
+
else if (char === "{")
|
|
55
|
+
this.#openBlock(idx);
|
|
56
|
+
else if (char === "}")
|
|
57
|
+
this.#closeBlock(idx);
|
|
58
|
+
else if (char === ";" && this.#parenDepth === 0)
|
|
59
|
+
this.#endStatement(idx);
|
|
60
|
+
idx += 1;
|
|
61
|
+
}
|
|
62
|
+
this.#endStatement(css.length);
|
|
63
|
+
return this.#stack[0];
|
|
64
|
+
}
|
|
65
|
+
get #current() {
|
|
66
|
+
return this.#stack[this.#stack.length - 1];
|
|
67
|
+
}
|
|
68
|
+
#skipString(start) {
|
|
69
|
+
const css = this.#css;
|
|
70
|
+
const quote = css[start];
|
|
71
|
+
let idx = start + 1;
|
|
72
|
+
while (idx < css.length) {
|
|
73
|
+
const char = css[idx];
|
|
74
|
+
if (char === "\\")
|
|
75
|
+
idx += 2;
|
|
76
|
+
else if (char === quote)
|
|
77
|
+
return idx + 1;
|
|
78
|
+
else if (char === `
|
|
79
|
+
`)
|
|
80
|
+
return idx;
|
|
81
|
+
else
|
|
82
|
+
idx += 1;
|
|
83
|
+
}
|
|
84
|
+
return css.length;
|
|
85
|
+
}
|
|
86
|
+
#takeSegment(end) {
|
|
87
|
+
const text = this.#pendingParts.join("") + this.#css.slice(this.#segmentStart, end);
|
|
88
|
+
this.#pendingParts = [];
|
|
89
|
+
this.#segmentStart = end + 1;
|
|
90
|
+
return text.trim();
|
|
91
|
+
}
|
|
92
|
+
#openBlock(idx) {
|
|
93
|
+
const prelude = this.#takeSegment(idx);
|
|
94
|
+
const block = { kind: "block", prelude, atRule: CssBlockParser.#atRuleOf(prelude), nodes: [] };
|
|
95
|
+
this.#current.nodes.push(block);
|
|
96
|
+
this.#stack.push(block);
|
|
97
|
+
this.#parenDepth = 0;
|
|
98
|
+
}
|
|
99
|
+
#closeBlock(idx) {
|
|
100
|
+
this.#endStatement(idx);
|
|
101
|
+
if (this.#stack.length > 1)
|
|
102
|
+
this.#stack.pop();
|
|
103
|
+
this.#parenDepth = 0;
|
|
104
|
+
}
|
|
105
|
+
#endStatement(idx) {
|
|
106
|
+
const text = this.#takeSegment(idx);
|
|
107
|
+
if (!text || text.startsWith("@"))
|
|
108
|
+
return;
|
|
109
|
+
const colon = text.indexOf(":");
|
|
110
|
+
if (colon <= 0)
|
|
111
|
+
return;
|
|
112
|
+
const property = text.slice(0, colon).trim();
|
|
113
|
+
if (!/^[\w-]+$/.test(property))
|
|
114
|
+
return;
|
|
115
|
+
this.#current.nodes.push({ kind: "declaration", property, value: text.slice(colon + 1).trim() });
|
|
116
|
+
}
|
|
117
|
+
static #atRuleOf(prelude) {
|
|
118
|
+
return prelude.match(/^@[\w-]+/)?.[0].toLowerCase() ?? null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// pkgs/@akanjs/devkit/frontendBuild/styleContract.ts
|
|
123
|
+
var countBlocking = (violations) => violations.theme.length;
|
|
124
|
+
var formatStyleContract = (violations) => violations.theme.flatMap((theme) => [
|
|
125
|
+
` [error] contrast ${theme.scope} ${theme.pair} = ${theme.ratio}:1 (min ${theme.threshold}:1)`,
|
|
126
|
+
` \u2192 ${theme.suggestion}`
|
|
127
|
+
]).join(`
|
|
128
|
+
`);
|
|
129
|
+
|
|
130
|
+
// pkgs/@akanjs/devkit/frontendBuild/themeValidator.ts
|
|
131
|
+
var PAIRS = [
|
|
132
|
+
{ base: "background", fg: "foreground", threshold: 4.5 },
|
|
133
|
+
{ base: "primary", fg: "primary-foreground", threshold: 4.5 },
|
|
134
|
+
{ base: "secondary", fg: "secondary-foreground", threshold: 4.5 },
|
|
135
|
+
{ base: "accent", fg: "accent-foreground", threshold: 4.5 },
|
|
136
|
+
{ base: "neutral", fg: "neutral-foreground", threshold: 4.5 },
|
|
137
|
+
{ base: "card", fg: "card-foreground", threshold: 4.5 },
|
|
138
|
+
{ base: "popover", fg: "popover-foreground", threshold: 4.5 },
|
|
139
|
+
{ base: "muted", fg: "muted-foreground", threshold: 3 },
|
|
140
|
+
{ base: "info", fg: "info-foreground", threshold: 3 },
|
|
141
|
+
{ base: "success", fg: "success-foreground", threshold: 3 },
|
|
142
|
+
{ base: "warning", fg: "warning-foreground", threshold: 3 },
|
|
143
|
+
{ base: "destructive", fg: "destructive-foreground", threshold: 3 },
|
|
144
|
+
{ base: "open", fg: "open-foreground", threshold: 3 }
|
|
145
|
+
];
|
|
146
|
+
var THEME_SCOPES = new Set([":root", '[data-theme="dark"]', '[data-theme="light"]']);
|
|
147
|
+
var CONDITIONAL_AT_RULES = new Set(["@media", "@supports", "@container"]);
|
|
148
|
+
|
|
149
|
+
class ThemeValidator {
|
|
150
|
+
validate(css) {
|
|
151
|
+
const tokensByScope = ThemeValidator.parseThemeTokens(css);
|
|
152
|
+
const violations = [];
|
|
153
|
+
for (const [scope, tokens] of Object.entries(tokensByScope)) {
|
|
154
|
+
const underlying = THEME_SCOPES.has(scope) ? null : [...THEME_SCOPES].find((name) => scope.endsWith(` ${name}`));
|
|
155
|
+
const effective = underlying ? ThemeValidator.#overlayPairs(tokensByScope[underlying] ?? {}, tokens) : tokens;
|
|
156
|
+
violations.push(...this.validateScope(effective, scope));
|
|
157
|
+
}
|
|
158
|
+
return violations;
|
|
159
|
+
}
|
|
160
|
+
validateScope(tokens, scope) {
|
|
161
|
+
const violations = [];
|
|
162
|
+
for (const { base, fg, threshold } of PAIRS) {
|
|
163
|
+
const bg = tokens[base];
|
|
164
|
+
const front = tokens[fg];
|
|
165
|
+
if (!bg || !front)
|
|
166
|
+
continue;
|
|
167
|
+
const bgRgb = ThemeValidator.parseHex(bg);
|
|
168
|
+
const fgRgb = ThemeValidator.parseHex(front);
|
|
169
|
+
if (!bgRgb || !fgRgb)
|
|
170
|
+
continue;
|
|
171
|
+
const ratio = ThemeValidator.contrastRatio(bgRgb, fgRgb);
|
|
172
|
+
if (ratio >= threshold)
|
|
173
|
+
continue;
|
|
174
|
+
violations.push({
|
|
175
|
+
scope,
|
|
176
|
+
pair: `${base} / ${fg}`,
|
|
177
|
+
background: bg,
|
|
178
|
+
foreground: front,
|
|
179
|
+
ratio: Math.round(ratio * 100) / 100,
|
|
180
|
+
threshold,
|
|
181
|
+
suggestion: `In ${scope}, --${base} (${bg}) against --${fg} (${front}) is ${ratio.toFixed(2)}:1, under the ${threshold}:1 minimum. Lighten or darken one of them until it clears.`
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return violations;
|
|
185
|
+
}
|
|
186
|
+
static parseThemeTokens(css) {
|
|
187
|
+
const result = {};
|
|
188
|
+
CssBlockParser.walk(CssBlockParser.parse(css), "", (node, condition) => {
|
|
189
|
+
if (node.kind !== "block")
|
|
190
|
+
return null;
|
|
191
|
+
if (node.atRule === "@layer")
|
|
192
|
+
return condition;
|
|
193
|
+
if (node.atRule)
|
|
194
|
+
return CONDITIONAL_AT_RULES.has(node.atRule) ? node.prelude.replace(/\s+/g, " ") : null;
|
|
195
|
+
const scopes = node.prelude.split(",").map((selector) => ThemeValidator.#normalizeScope(selector)).filter((scope) => THEME_SCOPES.has(scope));
|
|
196
|
+
if (scopes.length === 0)
|
|
197
|
+
return null;
|
|
198
|
+
const tokens = ThemeValidator.#customProperties(node);
|
|
199
|
+
for (const scope of scopes) {
|
|
200
|
+
const key = condition ? `${condition} ${scope}` : scope;
|
|
201
|
+
result[key] = Object.assign(result[key] ?? {}, tokens);
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
});
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
static #customProperties(block) {
|
|
208
|
+
const tokens = {};
|
|
209
|
+
for (const node of block.nodes) {
|
|
210
|
+
if (node.kind === "declaration" && node.property.startsWith("--"))
|
|
211
|
+
tokens[node.property.slice(2)] = node.value;
|
|
212
|
+
}
|
|
213
|
+
return tokens;
|
|
214
|
+
}
|
|
215
|
+
static #overlayPairs(underlying, tokens) {
|
|
216
|
+
const effective = {};
|
|
217
|
+
for (const name of PAIRS.flatMap(({ base, fg }) => [base, fg])) {
|
|
218
|
+
const value = tokens[name] ?? underlying[name];
|
|
219
|
+
if (value)
|
|
220
|
+
effective[name] = value;
|
|
221
|
+
}
|
|
222
|
+
return effective;
|
|
223
|
+
}
|
|
224
|
+
static #normalizeScope(selector) {
|
|
225
|
+
return selector.replace(/\[data-theme=['"]?([\w-]+)['"]?\]/g, '[data-theme="$1"]').trim();
|
|
226
|
+
}
|
|
227
|
+
static parseHex(value) {
|
|
228
|
+
const v = value.trim();
|
|
229
|
+
if (!v.startsWith("#"))
|
|
230
|
+
return null;
|
|
231
|
+
const hex = v.slice(1);
|
|
232
|
+
let full;
|
|
233
|
+
if (hex.length === 3 || hex.length === 4)
|
|
234
|
+
full = hex.slice(0, 3).split("").map((c) => c + c).join("");
|
|
235
|
+
else if (hex.length === 6 || hex.length === 8)
|
|
236
|
+
full = hex.slice(0, 6);
|
|
237
|
+
else
|
|
238
|
+
return null;
|
|
239
|
+
if (!/^[0-9a-fA-F]{6}$/.test(full))
|
|
240
|
+
return null;
|
|
241
|
+
const n = Number.parseInt(full, 16);
|
|
242
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
243
|
+
}
|
|
244
|
+
static #relativeLuminance([r, g, b]) {
|
|
245
|
+
const channel = (c) => {
|
|
246
|
+
const s = c / 255;
|
|
247
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
248
|
+
};
|
|
249
|
+
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
250
|
+
}
|
|
251
|
+
static contrastRatio(a, b) {
|
|
252
|
+
const la = ThemeValidator.#relativeLuminance(a);
|
|
253
|
+
const lb = ThemeValidator.#relativeLuminance(b);
|
|
254
|
+
const hi = Math.max(la, lb);
|
|
255
|
+
const lo = Math.min(la, lb);
|
|
256
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export { countBlocking, formatStyleContract, CssBlockParser, ThemeValidator };
|
|
@@ -22,26 +22,26 @@ import {
|
|
|
22
22
|
renderWorkflowApply,
|
|
23
23
|
renderWorkflowValidation,
|
|
24
24
|
renderWorkflowRunArtifact
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-033wne2j.js";
|
|
26
26
|
import {
|
|
27
27
|
AkanContextAnalyzer
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-nv79n88g.js";
|
|
29
29
|
import {
|
|
30
30
|
CommandContainer,
|
|
31
31
|
runner
|
|
32
|
-
} from "./index-
|
|
32
|
+
} from "./index-vkb9m4z7.js";
|
|
33
33
|
import {
|
|
34
34
|
ModuleScript
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-p2r64bpa.js";
|
|
36
36
|
import {
|
|
37
37
|
PrimitiveScript
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-4393nb4b.js";
|
|
39
39
|
import {
|
|
40
40
|
spawnShell
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-pg1t468s.js";
|
|
42
42
|
import {
|
|
43
43
|
ScalarScript
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-g9ks2k8c.js";
|
|
45
45
|
|
|
46
46
|
// pkgs/@akanjs/cli/workflow/workflow.runner.ts
|
|
47
47
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
@@ -4,26 +4,26 @@ import {
|
|
|
4
4
|
CloudApi,
|
|
5
5
|
CloudUpdates,
|
|
6
6
|
PipelineSecrets
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-jrmzcp66.js";
|
|
8
8
|
import {
|
|
9
9
|
PkgExecutor
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-g6ax17x4.js";
|
|
11
11
|
import {
|
|
12
12
|
NativePublicEnv,
|
|
13
13
|
UpdatePackFolder
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-35m6bzm7.js";
|
|
15
15
|
import {
|
|
16
16
|
script
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-vkb9m4z7.js";
|
|
18
18
|
import {
|
|
19
19
|
ApplicationScript
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-h6czey01.js";
|
|
21
21
|
import {
|
|
22
22
|
PackageScript
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-ebarbgba.js";
|
|
24
24
|
import {
|
|
25
25
|
CloudRunner
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-rc51f9ht.js";
|
|
27
27
|
|
|
28
28
|
// pkgs/@akanjs/cli/cloud/cloud.script.ts
|
|
29
29
|
import { Logger } from "akanjs/common";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
jsonText
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-033wne2j.js";
|
|
5
5
|
import {
|
|
6
6
|
akanMcpInstallTargets
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-nv79n88g.js";
|
|
8
8
|
import {
|
|
9
9
|
script
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-vkb9m4z7.js";
|
|
11
11
|
import {
|
|
12
12
|
ContextRunner2
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-zv5s8x58.js";
|
|
14
14
|
|
|
15
15
|
// pkgs/@akanjs/cli/context/context.script.ts
|
|
16
16
|
import { Logger } from "akanjs/common";
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-vkb9m4z7.js";
|
|
6
6
|
import {
|
|
7
7
|
LibSource,
|
|
8
8
|
formatLibStatuses,
|
|
9
9
|
LibExecutor
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-g6ax17x4.js";
|
|
11
11
|
|
|
12
12
|
// pkgs/@akanjs/cli/library/library.script.ts
|
|
13
13
|
import { Logger } from "akanjs/common";
|
|
@@ -77,6 +77,9 @@ class CodeAgentRpcHost2 {
|
|
|
77
77
|
case "set_model":
|
|
78
78
|
await this.#agent.setModel({ provider: command.provider, id: command.modelId });
|
|
79
79
|
return await this.#agent.state();
|
|
80
|
+
case "set_auto_compact":
|
|
81
|
+
this.#agent.setAutoCompactAt(command.percent);
|
|
82
|
+
return await this.#agent.state();
|
|
80
83
|
case "get_state":
|
|
81
84
|
return await this.#agent.state(command.sinceSeq === undefined ? {} : { sinceSeq: command.sinceSeq });
|
|
82
85
|
case "shutdown":
|
|
@@ -26,7 +26,7 @@ class ConfigLock {
|
|
|
26
26
|
}
|
|
27
27
|
static async#take(lockPath) {
|
|
28
28
|
const handle = await open(lockPath, "wx", 384).catch((error) => {
|
|
29
|
-
if (error.code === "EEXIST")
|
|
29
|
+
if (error.code === "EEXIST" || process.platform === "win32" && error.code === "EPERM")
|
|
30
30
|
return null;
|
|
31
31
|
throw error;
|
|
32
32
|
});
|
|
@@ -1,7 +1,70 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ConfigLock
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-bqbf654f.js";
|
|
5
|
+
|
|
6
|
+
// pkgs/@akanjs/devkit/codeAgent/agent/AkanCodeCompaction.ts
|
|
7
|
+
class AkanCodeCompaction2 {
|
|
8
|
+
static reserveFloor = 32768;
|
|
9
|
+
static steps = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
|
10
|
+
static isStep(percent) {
|
|
11
|
+
return AkanCodeCompaction2.steps.some((step) => step === percent);
|
|
12
|
+
}
|
|
13
|
+
static normalize(percent) {
|
|
14
|
+
if (percent === undefined)
|
|
15
|
+
return;
|
|
16
|
+
if (!AkanCodeCompaction2.isStep(percent))
|
|
17
|
+
throw new Error(`Autocompact takes a percent in steps of 10: ${AkanCodeCompaction2.steps.join(", ")}.`);
|
|
18
|
+
return percent === 100 ? undefined : percent;
|
|
19
|
+
}
|
|
20
|
+
static thresholdOf(contextWindow, percent) {
|
|
21
|
+
const share = percent ? Math.floor(contextWindow * percent / 100) : contextWindow;
|
|
22
|
+
return Math.min(share, contextWindow - AkanCodeCompaction2.reserveFloor);
|
|
23
|
+
}
|
|
24
|
+
static apply(settings, model, percent) {
|
|
25
|
+
const threshold = AkanCodeCompaction2.thresholdOf(model.contextWindow, percent);
|
|
26
|
+
settings.applyOverrides({
|
|
27
|
+
compaction: {
|
|
28
|
+
modelOverrides: { [`${model.provider}/${model.id}`]: { reserveTokens: model.contextWindow - threshold } }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
static problemOf(model, percent, keepRecentTokens) {
|
|
33
|
+
const name = `${model.provider}/${model.id}`;
|
|
34
|
+
if (model.contextWindow <= 0)
|
|
35
|
+
return `${name} declares no context window, so it has no share to compact at.`;
|
|
36
|
+
const threshold = AkanCodeCompaction2.thresholdOf(model.contextWindow, percent);
|
|
37
|
+
if (threshold >= keepRecentTokens)
|
|
38
|
+
return;
|
|
39
|
+
const k = (tokens) => `${Math.round(tokens / 1000)}k`;
|
|
40
|
+
return `Compacting at ${percent}% of the ${k(model.contextWindow)} window of ${name} starts at ${k(threshold)}, under the ${k(keepRecentTokens)} of recent turns every compaction keeps, so every turn would compact again.`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// pkgs/@akanjs/devkit/codeAgent/agent/akanCodePaths.ts
|
|
45
|
+
import { existsSync } from "fs";
|
|
46
|
+
import { homedir } from "os";
|
|
47
|
+
import path from "path";
|
|
48
|
+
var builtinSkillsDir = () => {
|
|
49
|
+
const candidates = [path.join(import.meta.dir, "skills"), path.join(import.meta.dir, "..", "skills")];
|
|
50
|
+
return candidates.find((candidate) => existsSync(candidate));
|
|
51
|
+
};
|
|
52
|
+
var globalDir = () => process.env.AKAN_CODE_HOME ?? path.join(homedir(), ".akan", "code");
|
|
53
|
+
var akanCodePaths2 = {
|
|
54
|
+
workspaceDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code"),
|
|
55
|
+
sessionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "sessions"),
|
|
56
|
+
extensionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "extensions"),
|
|
57
|
+
skillsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "skills"),
|
|
58
|
+
mailDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "mail"),
|
|
59
|
+
builtinSkillsDir,
|
|
60
|
+
mcpFile: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "mcp.json"),
|
|
61
|
+
globalMcpFile: () => path.join(globalDir(), "mcp.json"),
|
|
62
|
+
globalSkillsDir: () => path.join(globalDir(), "skills"),
|
|
63
|
+
globalDir,
|
|
64
|
+
authFile: () => path.join(globalDir(), "auth.json"),
|
|
65
|
+
mcpAuthFile: () => path.join(globalDir(), "mcpAuth.json"),
|
|
66
|
+
modelsFile: () => path.join(globalDir(), "models.json")
|
|
67
|
+
};
|
|
5
68
|
|
|
6
69
|
// pkgs/@akanjs/devkit/codeAgent/agent/SubagentPool.ts
|
|
7
70
|
import { codeAgentReadOnlyBuiltins } from "akanjs/common";
|
|
@@ -116,7 +179,7 @@ class SubagentPool2 {
|
|
|
116
179
|
}
|
|
117
180
|
}
|
|
118
181
|
async#run(id, kind, prompt, signal) {
|
|
119
|
-
const { CodeAgent } = await import("./CodeAgent-
|
|
182
|
+
const { CodeAgent } = await import("./CodeAgent-gzfc5t52.js");
|
|
120
183
|
const budget = this.#options.parent.tools.subagent;
|
|
121
184
|
const child = SubagentPool2.childOf(this.#options.parent, kind);
|
|
122
185
|
const agent = await CodeAgent.create({
|
|
@@ -166,31 +229,6 @@ class SubagentPool2 {
|
|
|
166
229
|
}
|
|
167
230
|
}
|
|
168
231
|
|
|
169
|
-
// pkgs/@akanjs/devkit/codeAgent/agent/akanCodePaths.ts
|
|
170
|
-
import { existsSync } from "fs";
|
|
171
|
-
import { homedir } from "os";
|
|
172
|
-
import path from "path";
|
|
173
|
-
var builtinSkillsDir = () => {
|
|
174
|
-
const candidates = [path.join(import.meta.dir, "skills"), path.join(import.meta.dir, "..", "skills")];
|
|
175
|
-
return candidates.find((candidate) => existsSync(candidate));
|
|
176
|
-
};
|
|
177
|
-
var globalDir = () => process.env.AKAN_CODE_HOME ?? path.join(homedir(), ".akan", "code");
|
|
178
|
-
var akanCodePaths2 = {
|
|
179
|
-
workspaceDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code"),
|
|
180
|
-
sessionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "sessions"),
|
|
181
|
-
extensionsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "extensions"),
|
|
182
|
-
skillsDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "skills"),
|
|
183
|
-
mailDir: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "mail"),
|
|
184
|
-
builtinSkillsDir,
|
|
185
|
-
mcpFile: (workspaceRoot) => path.join(workspaceRoot, ".akan", "code", "mcp.json"),
|
|
186
|
-
globalMcpFile: () => path.join(globalDir(), "mcp.json"),
|
|
187
|
-
globalSkillsDir: () => path.join(globalDir(), "skills"),
|
|
188
|
-
globalDir,
|
|
189
|
-
authFile: () => path.join(globalDir(), "auth.json"),
|
|
190
|
-
mcpAuthFile: () => path.join(globalDir(), "mcpAuth.json"),
|
|
191
|
-
modelsFile: () => path.join(globalDir(), "models.json")
|
|
192
|
-
};
|
|
193
|
-
|
|
194
232
|
// pkgs/@akanjs/devkit/codeAgent/tools/McpServerConfig.ts
|
|
195
233
|
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
196
234
|
import path2 from "path";
|
|
@@ -283,59 +321,6 @@ class McpServerConfig {
|
|
|
283
321
|
}
|
|
284
322
|
}
|
|
285
323
|
|
|
286
|
-
// pkgs/@akanjs/devkit/codeAgent/tools/McpTokenStore.ts
|
|
287
|
-
import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
288
|
-
import path3 from "path";
|
|
289
|
-
class McpTokenStore {
|
|
290
|
-
static file() {
|
|
291
|
-
return akanCodePaths2.mcpAuthFile();
|
|
292
|
-
}
|
|
293
|
-
static lockFile() {
|
|
294
|
-
return `${McpTokenStore.file()}.lock`;
|
|
295
|
-
}
|
|
296
|
-
static read(name) {
|
|
297
|
-
return McpTokenStore.#all()[name];
|
|
298
|
-
}
|
|
299
|
-
static names() {
|
|
300
|
-
return Object.keys(McpTokenStore.#all());
|
|
301
|
-
}
|
|
302
|
-
static write(name, auth) {
|
|
303
|
-
McpTokenStore.#save({ ...McpTokenStore.#all(), [name]: auth });
|
|
304
|
-
}
|
|
305
|
-
static clear(name) {
|
|
306
|
-
const all = McpTokenStore.#all();
|
|
307
|
-
if (!(name in all))
|
|
308
|
-
return false;
|
|
309
|
-
delete all[name];
|
|
310
|
-
McpTokenStore.#save(all);
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
|
-
static isExpired(auth) {
|
|
314
|
-
return auth.expiresAt !== undefined && auth.expiresAt <= Date.now() + McpTokenStore.skewMs;
|
|
315
|
-
}
|
|
316
|
-
static skewMs = 60000;
|
|
317
|
-
static #all() {
|
|
318
|
-
const file = McpTokenStore.file();
|
|
319
|
-
if (!existsSync3(file))
|
|
320
|
-
return {};
|
|
321
|
-
try {
|
|
322
|
-
const parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
323
|
-
return parsed.servers ?? {};
|
|
324
|
-
} catch {
|
|
325
|
-
return {};
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
static #save(servers) {
|
|
329
|
-
const file = McpTokenStore.file();
|
|
330
|
-
mkdirSync2(path3.dirname(file), { recursive: true, mode: 448 });
|
|
331
|
-
const temp = `${file}.${process.pid}.tmp`;
|
|
332
|
-
writeFileSync2(temp, `${JSON.stringify({ servers }, null, 2)}
|
|
333
|
-
`, { mode: 384 });
|
|
334
|
-
renameSync(temp, file);
|
|
335
|
-
chmodSync(file, 384);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
324
|
// pkgs/@akanjs/devkit/codeAgent/tools/McpOAuth.ts
|
|
340
325
|
import { createHash, randomBytes } from "crypto";
|
|
341
326
|
|
|
@@ -560,6 +545,59 @@ class McpOAuthLoopback {
|
|
|
560
545
|
}
|
|
561
546
|
}
|
|
562
547
|
|
|
548
|
+
// pkgs/@akanjs/devkit/codeAgent/tools/McpTokenStore.ts
|
|
549
|
+
import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
550
|
+
import path3 from "path";
|
|
551
|
+
class McpTokenStore {
|
|
552
|
+
static file() {
|
|
553
|
+
return akanCodePaths2.mcpAuthFile();
|
|
554
|
+
}
|
|
555
|
+
static lockFile() {
|
|
556
|
+
return `${McpTokenStore.file()}.lock`;
|
|
557
|
+
}
|
|
558
|
+
static read(name) {
|
|
559
|
+
return McpTokenStore.#all()[name];
|
|
560
|
+
}
|
|
561
|
+
static names() {
|
|
562
|
+
return Object.keys(McpTokenStore.#all());
|
|
563
|
+
}
|
|
564
|
+
static write(name, auth) {
|
|
565
|
+
McpTokenStore.#save({ ...McpTokenStore.#all(), [name]: auth });
|
|
566
|
+
}
|
|
567
|
+
static clear(name) {
|
|
568
|
+
const all = McpTokenStore.#all();
|
|
569
|
+
if (!(name in all))
|
|
570
|
+
return false;
|
|
571
|
+
delete all[name];
|
|
572
|
+
McpTokenStore.#save(all);
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
static isExpired(auth) {
|
|
576
|
+
return auth.expiresAt !== undefined && auth.expiresAt <= Date.now() + McpTokenStore.skewMs;
|
|
577
|
+
}
|
|
578
|
+
static skewMs = 60000;
|
|
579
|
+
static #all() {
|
|
580
|
+
const file = McpTokenStore.file();
|
|
581
|
+
if (!existsSync3(file))
|
|
582
|
+
return {};
|
|
583
|
+
try {
|
|
584
|
+
const parsed = JSON.parse(readFileSync2(file, "utf8"));
|
|
585
|
+
return parsed.servers ?? {};
|
|
586
|
+
} catch {
|
|
587
|
+
return {};
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
static #save(servers) {
|
|
591
|
+
const file = McpTokenStore.file();
|
|
592
|
+
mkdirSync2(path3.dirname(file), { recursive: true, mode: 448 });
|
|
593
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
594
|
+
writeFileSync2(temp, `${JSON.stringify({ servers }, null, 2)}
|
|
595
|
+
`, { mode: 384 });
|
|
596
|
+
renameSync(temp, file);
|
|
597
|
+
chmodSync(file, 384);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
563
601
|
// pkgs/@akanjs/devkit/codeAgent/tools/McpSignIn.ts
|
|
564
602
|
class McpSignIn {
|
|
565
603
|
static #refreshing = new Map;
|
|
@@ -697,4 +735,4 @@ ${stored.refreshToken}`;
|
|
|
697
735
|
}
|
|
698
736
|
}
|
|
699
737
|
|
|
700
|
-
export { SubagentPool2, akanCodePaths2, McpServerConfig, McpTokenStore, McpSignIn };
|
|
738
|
+
export { SubagentPool2, akanCodePaths2, McpServerConfig, McpTokenStore, McpSignIn, AkanCodeCompaction2 };
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-vkb9m4z7.js";
|
|
6
6
|
import {
|
|
7
7
|
FileSys2
|
|
8
8
|
} from "./index-52w0fvh8.js";
|
|
9
9
|
import {
|
|
10
10
|
PkgExecutor
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-g6ax17x4.js";
|
|
12
12
|
import {
|
|
13
13
|
TypeScriptDependencyScanner2
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-tvehn2sp.js";
|
|
15
15
|
|
|
16
16
|
// pkgs/@akanjs/cli/package/package.runner.ts
|
|
17
17
|
import path2 from "path";
|
|
@@ -159,10 +159,10 @@ class PackageRunner extends runner("package") {
|
|
|
159
159
|
const packageRuntimeDependencies = {
|
|
160
160
|
"@akanjs/devkit": [
|
|
161
161
|
"tailwind-scrollbar",
|
|
162
|
-
"@earendil-works/chord",
|
|
163
162
|
"@earendil-works/pi-agent-core",
|
|
164
163
|
"@earendil-works/pi-ai",
|
|
165
|
-
"@earendil-works/pi-
|
|
164
|
+
"@earendil-works/pi-codemode",
|
|
165
|
+
"@earendil-works/pi-mcp",
|
|
166
166
|
"@earendil-works/pi-tui"
|
|
167
167
|
]
|
|
168
168
|
};
|
|
@@ -273,7 +273,7 @@ class PackageRunner extends runner("package") {
|
|
|
273
273
|
if (!failures.length)
|
|
274
274
|
return;
|
|
275
275
|
throw new Error(`[package] ${pkg.name} dist imports ${failures.length} subpath(s) no consumer can resolve:
|
|
276
|
-
` + `${failures.sort().join(`
|
|
276
|
+
` + `${failures.sort((a, b) => a < b ? -1 : a > b ? 1 : 0).join(`
|
|
277
277
|
`)}
|
|
278
278
|
` + `Add the missing "exports" entries: a bare file facet needs "./*": "./*.ts", a directory facet ` + `needs its own "./name": "./name/index.ts", and "./*.ts": "./*.ts" keeps an already-suffixed ` + `specifier from gaining a second extension.`);
|
|
279
279
|
}
|