ccjk 12.2.2 → 12.3.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.
- package/dist/chunks/agent-teams.mjs +3 -3
- package/dist/chunks/agent.mjs +2 -2
- package/dist/chunks/agents.mjs +4 -5
- package/dist/chunks/api-cli.mjs +5 -5
- package/dist/chunks/api-providers.mjs +1 -1
- package/dist/chunks/api.mjs +4 -4
- package/dist/chunks/auto-bootstrap.mjs +1 -1
- package/dist/chunks/auto-fixer.mjs +3 -3
- package/dist/chunks/auto-init.mjs +3 -3
- package/dist/chunks/auto-updater.mjs +9 -9
- package/dist/chunks/banner.mjs +2 -2
- package/dist/chunks/boost.mjs +4 -4
- package/dist/chunks/ccjk-agents.mjs +3 -3
- package/dist/chunks/ccjk-all.mjs +6 -6
- package/dist/chunks/ccjk-config.mjs +2 -2
- package/dist/chunks/ccjk-hooks.mjs +4 -4
- package/dist/chunks/ccjk-mcp.mjs +5 -5
- package/dist/chunks/ccjk-setup.mjs +5 -5
- package/dist/chunks/ccjk-skills.mjs +5 -5
- package/dist/chunks/ccr.mjs +14 -14
- package/dist/chunks/ccu.mjs +2 -2
- package/dist/chunks/check-updates.mjs +6 -6
- package/dist/chunks/claude-code-config-manager.mjs +4 -4
- package/dist/chunks/claude-code-incremental-manager.mjs +6 -6
- package/dist/chunks/claude-config.mjs +1 -1
- package/dist/chunks/claude-wrapper.mjs +1 -1
- package/dist/chunks/cli-hook.mjs +9 -10
- package/dist/chunks/codex-config-switch.mjs +6 -6
- package/dist/chunks/codex-provider-manager.mjs +6 -6
- package/dist/chunks/codex-uninstaller.mjs +2 -2
- package/dist/chunks/codex.mjs +5 -5
- package/dist/chunks/commands.mjs +2 -2
- package/dist/chunks/commands2.mjs +1 -1
- package/dist/chunks/commit.mjs +2 -2
- package/dist/chunks/completion.mjs +2 -2
- package/dist/chunks/config-consolidator.mjs +2 -2
- package/dist/chunks/config-switch.mjs +7 -7
- package/dist/chunks/config.mjs +3 -3
- package/dist/chunks/config2.mjs +4 -4
- package/dist/chunks/config3.mjs +3 -3
- package/dist/chunks/constants.mjs +1 -1
- package/dist/chunks/context-opt.mjs +442 -0
- package/dist/chunks/convoy-manager.mjs +355 -3
- package/dist/chunks/dashboard.mjs +2 -2
- package/dist/chunks/doctor.mjs +4 -4
- package/dist/chunks/evolution.mjs +2 -2
- package/dist/chunks/health-alerts.mjs +530 -4
- package/dist/chunks/help.mjs +1 -1
- package/dist/chunks/index.mjs +0 -23
- package/dist/chunks/index10.mjs +571 -634
- package/dist/chunks/index11.mjs +569 -1061
- package/dist/chunks/index12.mjs +1076 -914
- package/dist/chunks/index13.mjs +951 -135
- package/dist/chunks/index14.mjs +184 -209
- package/dist/chunks/index15.mjs +218 -0
- package/dist/chunks/index2.mjs +24 -19
- package/dist/chunks/index3.mjs +12 -19085
- package/dist/chunks/index4.mjs +19092 -16
- package/dist/chunks/index5.mjs +16 -7602
- package/dist/chunks/index6.mjs +7590 -159
- package/dist/chunks/index7.mjs +171 -1602
- package/dist/chunks/index8.mjs +1602 -19
- package/dist/chunks/index9.mjs +15 -612
- package/dist/chunks/init.mjs +13 -13
- package/dist/chunks/installer.mjs +5 -5
- package/dist/chunks/installer2.mjs +1 -1
- package/dist/chunks/interview.mjs +4 -4
- package/dist/chunks/manager.mjs +1 -1
- package/dist/chunks/marketplace.mjs +2 -2
- package/dist/chunks/mcp-cli.mjs +9 -9
- package/dist/chunks/mcp.mjs +7 -7
- package/dist/chunks/memory.mjs +3 -3
- package/dist/chunks/menu-hierarchical.mjs +14 -14
- package/dist/chunks/menu.mjs +12 -12
- package/dist/chunks/metrics-display.mjs +1 -1
- package/dist/chunks/migrator.mjs +1 -1
- package/dist/chunks/monitor.mjs +2 -2
- package/dist/chunks/notification.mjs +4 -4
- package/dist/chunks/onboarding-wizard.mjs +2 -2
- package/dist/chunks/onboarding.mjs +4 -4
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/paradigm.mjs +1 -1
- package/dist/chunks/permission-manager.mjs +2 -2
- package/dist/chunks/permissions.mjs +3 -3
- package/dist/chunks/persistence-manager.mjs +3 -3
- package/dist/chunks/plugin.mjs +2 -2
- package/dist/chunks/prompts.mjs +5 -5
- package/dist/chunks/providers.mjs +2 -2
- package/dist/chunks/quick-actions.mjs +2 -2
- package/dist/chunks/quick-provider.mjs +6 -5
- package/dist/chunks/quick-setup.mjs +10 -10
- package/dist/chunks/remote.mjs +5 -5
- package/dist/chunks/session.mjs +2 -2
- package/dist/chunks/sessions.mjs +1 -1
- package/dist/chunks/silent-updater.mjs +1 -1
- package/dist/chunks/simple-config.mjs +1 -1
- package/dist/chunks/skill2.mjs +3 -3
- package/dist/chunks/skills-sync.mjs +4 -4
- package/dist/chunks/skills.mjs +3 -3
- package/dist/chunks/slash-commands.mjs +3 -3
- package/dist/chunks/startup.mjs +1 -1
- package/dist/chunks/stats.mjs +2 -2
- package/dist/chunks/status.mjs +2 -2
- package/dist/chunks/team.mjs +3 -3
- package/dist/chunks/thinking.mjs +4 -4
- package/dist/chunks/trace.mjs +2 -2
- package/dist/chunks/uninstall.mjs +8 -8
- package/dist/chunks/update.mjs +9 -9
- package/dist/chunks/upgrade-manager.mjs +3 -3
- package/dist/chunks/version-checker.mjs +4 -4
- package/dist/chunks/vim.mjs +3 -3
- package/dist/chunks/workflows.mjs +1 -1
- package/dist/chunks/wsl.mjs +1 -1
- package/dist/chunks/zero-config.mjs +3 -3
- package/dist/cli.mjs +56 -23
- package/dist/index.mjs +5 -5
- package/dist/shared/{ccjk.CCcQfbni.mjs → ccjk.B1TwPltj.mjs} +1 -1
- package/dist/shared/{ccjk.CePkJq2S.mjs → ccjk.BfIpomdz.mjs} +1 -1
- package/dist/shared/{ccjk.D8ZLYSZZ.mjs → ccjk.CXzjn01x.mjs} +1 -1
- package/dist/shared/{ccjk.Cjj8SVrn.mjs → ccjk.Cot9p9_n.mjs} +1 -1
- package/dist/shared/{ccjk.CvChMYvB.mjs → ccjk.DCw2WnZU.mjs} +1 -1
- package/dist/shared/{ccjk.DG_o24cZ.mjs → ccjk.DJdmgr2d.mjs} +1 -1
- package/dist/shared/{ccjk.BIxuVL3_.mjs → ccjk.DcKLglJQ.mjs} +2 -2
- package/dist/shared/{ccjk.DLLw-h4Y.mjs → ccjk.DfXjf8EC.mjs} +2 -2
- package/dist/shared/{ccjk.KpFl2RDA.mjs → ccjk.DpstNaeR.mjs} +3 -3
- package/dist/shared/{ccjk.DOBWBkFR.mjs → ccjk.XsJWJuQP.mjs} +5 -5
- package/dist/shared/{ccjk._dESH4Rk.mjs → ccjk.dYDLfmph.mjs} +1 -1
- package/dist/shared/{ccjk.DS7UESmF.mjs → ccjk.hrRv8G6j.mjs} +4 -4
- package/dist/shared/{ccjk.BWFpnOr3.mjs → ccjk.mJpVRDZ8.mjs} +1 -1
- package/dist/templates/claude-code/common/settings.json +3 -1
- package/package.json +20 -18
- package/templates/claude-code/common/settings.json +3 -1
- package/dist/chunks/context-loader.mjs +0 -351
- package/dist/chunks/context.mjs +0 -372
- package/dist/chunks/health-check.mjs +0 -532
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { glob } from 'tinyglobby';
|
|
3
|
-
import { e as executionTracer } from '../shared/ccjk.CePkJq2S.mjs';
|
|
4
|
-
import { f as fsParadigm } from '../shared/ccjk.BxSmJ8B7.mjs';
|
|
5
|
-
import { j as join } from '../shared/ccjk.bQ7Dh1g4.mjs';
|
|
6
|
-
import './index2.mjs';
|
|
7
|
-
import '../shared/ccjk.BAGoDD49.mjs';
|
|
8
|
-
|
|
9
|
-
const DEPTH_TOKEN_BUDGETS = {
|
|
10
|
-
L0: 100,
|
|
11
|
-
// Abstract summary only
|
|
12
|
-
L1: 2e3,
|
|
13
|
-
// Overview
|
|
14
|
-
L2: Number.POSITIVE_INFINITY
|
|
15
|
-
// Full content
|
|
16
|
-
};
|
|
17
|
-
const PHASE_BUDGET_MULTIPLIERS = {
|
|
18
|
-
exploring: 2,
|
|
19
|
-
executing: 0.6,
|
|
20
|
-
generating: 0.4,
|
|
21
|
-
reviewing: 1.2,
|
|
22
|
-
idle: 1
|
|
23
|
-
};
|
|
24
|
-
const CHARS_PER_TOKEN = 4;
|
|
25
|
-
function estimateTokens(text) {
|
|
26
|
-
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
27
|
-
}
|
|
28
|
-
function truncateToDepth(content, depth) {
|
|
29
|
-
if (depth === "L2") return content;
|
|
30
|
-
const maxChars = DEPTH_TOKEN_BUDGETS[depth] * CHARS_PER_TOKEN;
|
|
31
|
-
if (content.length <= maxChars) return content;
|
|
32
|
-
if (depth === "L0") {
|
|
33
|
-
const firstPara = content.split(/\n\n/)[0];
|
|
34
|
-
return firstPara.length <= maxChars ? firstPara : content.slice(0, maxChars);
|
|
35
|
-
}
|
|
36
|
-
return `${content.slice(0, maxChars)}
|
|
37
|
-
... (truncated, use L2 for full content)`;
|
|
38
|
-
}
|
|
39
|
-
class ContextLoader {
|
|
40
|
-
cache = /* @__PURE__ */ new Map();
|
|
41
|
-
defaultMaxSize = 1e5;
|
|
42
|
-
// 100KB default
|
|
43
|
-
defaultTokenBudget = 8e3;
|
|
44
|
-
// ~32KB at 4 chars/token
|
|
45
|
-
/**
|
|
46
|
-
* Resolve effective depth from options.
|
|
47
|
-
* If depth is explicit, use it. Otherwise derive from tokenBudget.
|
|
48
|
-
*/
|
|
49
|
-
resolveDepth(tokenBudget, explicitDepth) {
|
|
50
|
-
if (explicitDepth) return explicitDepth;
|
|
51
|
-
if (tokenBudget <= DEPTH_TOKEN_BUDGETS.L0) return "L0";
|
|
52
|
-
if (tokenBudget <= DEPTH_TOKEN_BUDGETS.L1) return "L1";
|
|
53
|
-
return "L2";
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Load context hierarchically with OpenViking-style tiered depth control.
|
|
57
|
-
* Pass tokenBudget to automatically select L0/L1/L2 depth.
|
|
58
|
-
*/
|
|
59
|
-
async load(options = {}) {
|
|
60
|
-
const {
|
|
61
|
-
projectRoot = process.cwd(),
|
|
62
|
-
maxSize = this.defaultMaxSize,
|
|
63
|
-
tokenBudget,
|
|
64
|
-
depth: explicitDepth,
|
|
65
|
-
layers = ["project", "domain", "task", "execution"],
|
|
66
|
-
task
|
|
67
|
-
} = options;
|
|
68
|
-
const phaseMultiplier = options.taskPhase ? PHASE_BUDGET_MULTIPLIERS[options.taskPhase] ?? 1 : 1;
|
|
69
|
-
const effectiveBudget = Math.round((tokenBudget ?? this.defaultTokenBudget) * phaseMultiplier);
|
|
70
|
-
const depth = this.resolveDepth(effectiveBudget, explicitDepth);
|
|
71
|
-
const cacheKey = this.getCacheKey(projectRoot, layers, task?.id, depth);
|
|
72
|
-
const cached = this.cache.get(cacheKey);
|
|
73
|
-
if (cached && Date.now() - cached.loadedAt < 6e4) {
|
|
74
|
-
executionTracer.logEvent("context-load", {
|
|
75
|
-
source: "cache",
|
|
76
|
-
layers: layers.length,
|
|
77
|
-
size: cached.totalSize,
|
|
78
|
-
tokens: cached.totalTokens,
|
|
79
|
-
depth
|
|
80
|
-
});
|
|
81
|
-
return cached;
|
|
82
|
-
}
|
|
83
|
-
const context = {
|
|
84
|
-
layers: /* @__PURE__ */ new Map(),
|
|
85
|
-
totalSize: 0,
|
|
86
|
-
totalTokens: 0,
|
|
87
|
-
loadedAt: Date.now(),
|
|
88
|
-
depth
|
|
89
|
-
};
|
|
90
|
-
for (const layer of layers) {
|
|
91
|
-
const entries = await this.loadLayer(layer, projectRoot, task, depth);
|
|
92
|
-
if (entries.length > 0) {
|
|
93
|
-
context.layers.set(layer, entries);
|
|
94
|
-
context.totalSize += entries.reduce((sum, e) => sum + e.content.length, 0);
|
|
95
|
-
context.totalTokens += entries.reduce((sum, e) => sum + e.tokenEstimate, 0);
|
|
96
|
-
}
|
|
97
|
-
if (context.totalSize > maxSize || context.totalTokens > effectiveBudget) {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
this.cache.set(cacheKey, context);
|
|
102
|
-
executionTracer.logEvent("context-load", {
|
|
103
|
-
source: "fresh",
|
|
104
|
-
layers: context.layers.size,
|
|
105
|
-
size: context.totalSize,
|
|
106
|
-
tokens: context.totalTokens,
|
|
107
|
-
depth
|
|
108
|
-
});
|
|
109
|
-
return context;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Load a specific context layer
|
|
113
|
-
*/
|
|
114
|
-
async loadLayer(layer, projectRoot, task, depth = "L2") {
|
|
115
|
-
switch (layer) {
|
|
116
|
-
case "project":
|
|
117
|
-
return this.loadProjectContext(projectRoot, depth);
|
|
118
|
-
case "domain":
|
|
119
|
-
return this.loadDomainContext(projectRoot, task, depth);
|
|
120
|
-
case "task":
|
|
121
|
-
return this.loadTaskContext(task, depth);
|
|
122
|
-
case "execution":
|
|
123
|
-
return this.loadExecutionContext(task, depth);
|
|
124
|
-
default:
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Load project-level context
|
|
130
|
-
* - README.md
|
|
131
|
-
* - CLAUDE.md
|
|
132
|
-
* - package.json
|
|
133
|
-
* - tsconfig.json
|
|
134
|
-
*/
|
|
135
|
-
async loadProjectContext(projectRoot, depth = "L2") {
|
|
136
|
-
const entries = [];
|
|
137
|
-
const files = ["README.md", "CLAUDE.md", "package.json", "tsconfig.json"];
|
|
138
|
-
for (const file of files) {
|
|
139
|
-
const path = join(projectRoot, file);
|
|
140
|
-
if (existsSync(path)) {
|
|
141
|
-
const raw = readFileSync(path, "utf-8");
|
|
142
|
-
const content = truncateToDepth(raw, depth);
|
|
143
|
-
entries.push({
|
|
144
|
-
layer: "project",
|
|
145
|
-
source: file,
|
|
146
|
-
content,
|
|
147
|
-
priority: 100,
|
|
148
|
-
depth,
|
|
149
|
-
tokenEstimate: estimateTokens(content),
|
|
150
|
-
metadata: { path }
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return entries;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Load domain-specific context
|
|
158
|
-
* Based on task type/domain, load relevant files
|
|
159
|
-
*/
|
|
160
|
-
async loadDomainContext(projectRoot, task, depth = "L2") {
|
|
161
|
-
if (!task) return [];
|
|
162
|
-
const entries = [];
|
|
163
|
-
const structure = await fsParadigm.detect(projectRoot);
|
|
164
|
-
const domain = this.inferDomain(task);
|
|
165
|
-
if (!domain) {
|
|
166
|
-
const sourceFiles = fsParadigm.getFilesByRole(structure, "source");
|
|
167
|
-
for (const file of sourceFiles.slice(0, 3)) {
|
|
168
|
-
try {
|
|
169
|
-
const raw = readFileSync(file, "utf-8");
|
|
170
|
-
const content = truncateToDepth(raw, depth);
|
|
171
|
-
entries.push({
|
|
172
|
-
layer: "domain",
|
|
173
|
-
source: file.replace(projectRoot, ""),
|
|
174
|
-
content,
|
|
175
|
-
priority: 75,
|
|
176
|
-
depth,
|
|
177
|
-
tokenEstimate: estimateTokens(content),
|
|
178
|
-
metadata: { paradigm: structure.paradigm, path: file }
|
|
179
|
-
});
|
|
180
|
-
} catch {
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return entries;
|
|
184
|
-
}
|
|
185
|
-
const patterns = this.getDomainPatterns(domain, structure.paradigm);
|
|
186
|
-
for (const pattern of patterns) {
|
|
187
|
-
const files = await glob([pattern], {
|
|
188
|
-
cwd: projectRoot,
|
|
189
|
-
absolute: true,
|
|
190
|
-
ignore: ["**/node_modules/**", "**/dist/**", "**/.git/**"]
|
|
191
|
-
});
|
|
192
|
-
for (const file of files.slice(0, 5)) {
|
|
193
|
-
try {
|
|
194
|
-
const raw = readFileSync(file, "utf-8");
|
|
195
|
-
const content = truncateToDepth(raw, depth);
|
|
196
|
-
entries.push({
|
|
197
|
-
layer: "domain",
|
|
198
|
-
source: file.replace(projectRoot, ""),
|
|
199
|
-
content,
|
|
200
|
-
priority: 80,
|
|
201
|
-
depth,
|
|
202
|
-
tokenEstimate: estimateTokens(content),
|
|
203
|
-
metadata: { domain, paradigm: structure.paradigm, path: file }
|
|
204
|
-
});
|
|
205
|
-
} catch {
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return entries;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Load task-specific context
|
|
213
|
-
*/
|
|
214
|
-
async loadTaskContext(task, depth = "L2") {
|
|
215
|
-
if (!task) return [];
|
|
216
|
-
const entries = [];
|
|
217
|
-
if (task.description) {
|
|
218
|
-
const content = truncateToDepth(task.description, depth);
|
|
219
|
-
entries.push({
|
|
220
|
-
layer: "task",
|
|
221
|
-
source: "task-description",
|
|
222
|
-
content,
|
|
223
|
-
priority: 90,
|
|
224
|
-
depth,
|
|
225
|
-
tokenEstimate: estimateTokens(content),
|
|
226
|
-
metadata: { taskId: task.id }
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (task.input && depth !== "L0") {
|
|
230
|
-
const content = truncateToDepth(JSON.stringify(task.input, null, 2), depth);
|
|
231
|
-
entries.push({
|
|
232
|
-
layer: "task",
|
|
233
|
-
source: "task-input",
|
|
234
|
-
content,
|
|
235
|
-
priority: 85,
|
|
236
|
-
depth,
|
|
237
|
-
tokenEstimate: estimateTokens(content),
|
|
238
|
-
metadata: { taskId: task.id }
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
return entries;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Load execution-specific context
|
|
245
|
-
* - Recent errors
|
|
246
|
-
* - Previous attempts
|
|
247
|
-
* - Related task outputs
|
|
248
|
-
*/
|
|
249
|
-
async loadExecutionContext(task, depth = "L2") {
|
|
250
|
-
if (!task) return [];
|
|
251
|
-
const entries = [];
|
|
252
|
-
if (task.output && depth !== "L0") {
|
|
253
|
-
const content = truncateToDepth(JSON.stringify(task.output, null, 2), depth);
|
|
254
|
-
entries.push({
|
|
255
|
-
layer: "execution",
|
|
256
|
-
source: "previous-output",
|
|
257
|
-
content,
|
|
258
|
-
priority: 70,
|
|
259
|
-
depth,
|
|
260
|
-
tokenEstimate: estimateTokens(content),
|
|
261
|
-
metadata: { taskId: task.id }
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
return entries;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Infer domain from task
|
|
268
|
-
*/
|
|
269
|
-
inferDomain(task) {
|
|
270
|
-
const text = `${task.name} ${task.description || ""}`.toLowerCase();
|
|
271
|
-
const domains = {
|
|
272
|
-
api: ["api", "endpoint", "route", "controller"],
|
|
273
|
-
ui: ["ui", "component", "view", "page", "frontend"],
|
|
274
|
-
database: ["database", "db", "schema", "migration", "model"],
|
|
275
|
-
auth: ["auth", "login", "user", "permission", "session"],
|
|
276
|
-
test: ["test", "spec", "e2e", "unit", "integration"],
|
|
277
|
-
config: ["config", "settings", "env", "setup"]
|
|
278
|
-
};
|
|
279
|
-
for (const [domain, keywords] of Object.entries(domains)) {
|
|
280
|
-
if (keywords.some((kw) => text.includes(kw))) {
|
|
281
|
-
return domain;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return null;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Get file patterns for a domain (paradigm-aware)
|
|
288
|
-
*/
|
|
289
|
-
getDomainPatterns(domain, paradigm) {
|
|
290
|
-
const basePatterns = {
|
|
291
|
-
api: ["**/api/**/*.ts", "**/routes/**/*.ts", "**/controllers/**/*.ts"],
|
|
292
|
-
ui: ["**/components/**/*.{tsx,vue}", "**/pages/**/*.{tsx,vue}", "**/views/**/*.{tsx,vue}"],
|
|
293
|
-
database: ["**/models/**/*.ts", "**/schema/**/*.ts", "**/migrations/**/*.ts"],
|
|
294
|
-
auth: ["**/auth/**/*.ts", "**/middleware/auth*.ts"],
|
|
295
|
-
test: ["**/*.test.ts", "**/*.spec.ts"],
|
|
296
|
-
config: ["**/config/**/*.ts", "**/*.config.ts"]
|
|
297
|
-
};
|
|
298
|
-
let patterns = basePatterns[domain] || [];
|
|
299
|
-
if (paradigm === "monorepo") {
|
|
300
|
-
patterns = patterns.map((p) => `packages/*/${p}`);
|
|
301
|
-
} else if (paradigm === "fullstack") {
|
|
302
|
-
if (domain === "ui") {
|
|
303
|
-
patterns = patterns.map((p) => `client/${p}`);
|
|
304
|
-
} else if (domain === "api") {
|
|
305
|
-
patterns = patterns.map((p) => `server/${p}`);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return patterns;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Get cache key
|
|
312
|
-
*/
|
|
313
|
-
getCacheKey(projectRoot, layers, taskId, depth = "L2") {
|
|
314
|
-
return `${projectRoot}:${layers.join(",")}:${taskId || "none"}:${depth}`;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Clear cache
|
|
318
|
-
*/
|
|
319
|
-
clearCache() {
|
|
320
|
-
this.cache.clear();
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Format context for LLM consumption
|
|
324
|
-
*/
|
|
325
|
-
formatForLLM(context) {
|
|
326
|
-
const sections = [];
|
|
327
|
-
sections.push(`<!-- context depth=${context.depth} tokens\u2248${context.totalTokens} -->
|
|
328
|
-
`);
|
|
329
|
-
const layerOrder = ["project", "domain", "task", "execution"];
|
|
330
|
-
for (const layer of layerOrder) {
|
|
331
|
-
const entries = context.layers.get(layer);
|
|
332
|
-
if (!entries || entries.length === 0) continue;
|
|
333
|
-
sections.push(`# ${layer.toUpperCase()} CONTEXT
|
|
334
|
-
`);
|
|
335
|
-
const sorted = entries.sort((a, b) => b.priority - a.priority);
|
|
336
|
-
for (const entry of sorted) {
|
|
337
|
-
sections.push(`## ${entry.source} [${entry.depth}]
|
|
338
|
-
`);
|
|
339
|
-
sections.push(entry.content);
|
|
340
|
-
sections.push("\n");
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return sections.join("\n");
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
const contextLoader = new ContextLoader();
|
|
347
|
-
async function loadContextAtDepth(depth, options = {}) {
|
|
348
|
-
return contextLoader.load({ ...options, depth });
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
export { ContextLoader, contextLoader, loadContextAtDepth };
|