@stackmemoryai/stackmemory 0.3.7 → 0.3.8
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/agents/core/agent-task-manager.js +5 -5
- package/dist/agents/core/agent-task-manager.js.map +2 -2
- package/dist/agents/verifiers/base-verifier.js +2 -2
- package/dist/agents/verifiers/base-verifier.js.map +2 -2
- package/dist/cli/claude-sm.js +0 -11
- package/dist/cli/claude-sm.js.map +2 -2
- package/dist/cli/codex-sm.js +0 -11
- package/dist/cli/codex-sm.js.map +2 -2
- package/dist/cli/commands/chromadb.js +64 -34
- package/dist/cli/commands/chromadb.js.map +2 -2
- package/dist/cli/commands/clear.js +9 -13
- package/dist/cli/commands/clear.js.map +2 -2
- package/dist/cli/commands/config.js +43 -33
- package/dist/cli/commands/config.js.map +2 -2
- package/dist/cli/commands/context.js.map +2 -2
- package/dist/cli/commands/dashboard.js +41 -13
- package/dist/cli/commands/dashboard.js.map +2 -2
- package/dist/cli/commands/gc.js +69 -20
- package/dist/cli/commands/gc.js.map +2 -2
- package/dist/cli/commands/handoff.js.map +2 -2
- package/dist/cli/commands/infinite-storage.js +60 -19
- package/dist/cli/commands/infinite-storage.js.map +2 -2
- package/dist/cli/commands/linear-create.js +36 -8
- package/dist/cli/commands/linear-create.js.map +2 -2
- package/dist/cli/commands/linear-list.js +33 -10
- package/dist/cli/commands/linear-list.js.map +2 -2
- package/dist/cli/commands/linear-migrate.js +17 -4
- package/dist/cli/commands/linear-migrate.js.map +2 -2
- package/dist/cli/commands/linear-test.js +14 -6
- package/dist/cli/commands/linear-test.js.map +2 -2
- package/dist/cli/commands/linear-unified.js +123 -35
- package/dist/cli/commands/linear-unified.js.map +2 -2
- package/dist/cli/commands/linear.js.map +2 -2
- package/dist/cli/commands/monitor.js.map +2 -2
- package/dist/cli/commands/onboard.js +35 -8
- package/dist/cli/commands/onboard.js.map +2 -2
- package/dist/cli/commands/quality.js +2 -7
- package/dist/cli/commands/quality.js.map +2 -2
- package/dist/cli/commands/session.js +23 -6
- package/dist/cli/commands/session.js.map +2 -2
- package/dist/cli/commands/skills.js +72 -27
- package/dist/cli/commands/skills.js.map +2 -2
- package/dist/cli/commands/storage.js +108 -38
- package/dist/cli/commands/storage.js.map +2 -2
- package/dist/cli/commands/tui.js.map +2 -2
- package/dist/cli/commands/webhook.js +57 -18
- package/dist/cli/commands/webhook.js.map +2 -2
- package/dist/cli/commands/workflow.js +8 -15
- package/dist/cli/commands/workflow.js.map +2 -2
- package/dist/cli/commands/worktree.js +34 -13
- package/dist/cli/commands/worktree.js.map +2 -2
- package/dist/cli/index.js +0 -11
- package/dist/cli/index.js.map +2 -2
- package/dist/core/config/types.js.map +1 -1
- package/dist/core/context/auto-context.js +10 -6
- package/dist/core/context/auto-context.js.map +2 -2
- package/dist/core/context/context-bridge.js.map +2 -2
- package/dist/core/context/frame-database.js +13 -3
- package/dist/core/context/frame-database.js.map +2 -2
- package/dist/core/context/frame-digest.js +7 -5
- package/dist/core/context/frame-digest.js.map +2 -2
- package/dist/core/context/frame-manager.js.map +2 -2
- package/dist/core/context/frame-stack.js +16 -5
- package/dist/core/context/frame-stack.js.map +2 -2
- package/dist/core/context/incremental-gc.js +10 -3
- package/dist/core/context/incremental-gc.js.map +2 -2
- package/dist/core/context/index.js.map +1 -1
- package/dist/core/context/permission-manager.js.map +2 -2
- package/dist/core/context/refactored-frame-manager.js +12 -3
- package/dist/core/context/refactored-frame-manager.js.map +2 -2
- package/dist/core/context/shared-context-layer.js +4 -2
- package/dist/core/context/shared-context-layer.js.map +2 -2
- package/dist/core/database/batch-operations.js +112 -86
- package/dist/core/database/batch-operations.js.map +2 -2
- package/dist/core/database/query-cache.js +19 -9
- package/dist/core/database/query-cache.js.map +2 -2
- package/dist/core/database/sqlite-adapter.js +1 -1
- package/dist/core/database/sqlite-adapter.js.map +2 -2
- package/dist/core/digest/enhanced-hybrid-digest.js +8 -2
- package/dist/core/digest/enhanced-hybrid-digest.js.map +2 -2
- package/dist/core/errors/recovery.js +9 -2
- package/dist/core/errors/recovery.js.map +2 -2
- package/dist/core/frame/workflow-templates-stub.js.map +1 -1
- package/dist/core/frame/workflow-templates.js +40 -1
- package/dist/core/frame/workflow-templates.js.map +2 -2
- package/dist/core/monitoring/logger.js +6 -1
- package/dist/core/monitoring/logger.js.map +2 -2
- package/dist/core/monitoring/metrics.js.map +2 -2
- package/dist/core/monitoring/progress-tracker.js.map +2 -2
- package/dist/core/performance/context-cache.js.map +2 -2
- package/dist/core/performance/lazy-context-loader.js +24 -20
- package/dist/core/performance/lazy-context-loader.js.map +2 -2
- package/dist/core/performance/optimized-frame-context.js +27 -12
- package/dist/core/performance/optimized-frame-context.js.map +2 -2
- package/dist/core/performance/performance-benchmark.js +10 -6
- package/dist/core/performance/performance-benchmark.js.map +2 -2
- package/dist/core/performance/performance-profiler.js +51 -14
- package/dist/core/performance/performance-profiler.js.map +2 -2
- package/dist/core/performance/streaming-jsonl-parser.js +5 -1
- package/dist/core/performance/streaming-jsonl-parser.js.map +2 -2
- package/dist/core/projects/project-manager.js +14 -20
- package/dist/core/projects/project-manager.js.map +2 -2
- package/dist/core/retrieval/context-retriever.js.map +1 -1
- package/dist/core/retrieval/llm-context-retrieval.js.map +2 -2
- package/dist/core/session/clear-survival-stub.js +5 -1
- package/dist/core/session/clear-survival-stub.js.map +2 -2
- package/dist/core/session/clear-survival.js +35 -0
- package/dist/core/session/clear-survival.js.map +2 -2
- package/dist/core/session/index.js.map +1 -1
- package/dist/core/session/session-manager.js.map +2 -2
- package/dist/core/storage/chromadb-adapter.js +6 -2
- package/dist/core/storage/chromadb-adapter.js.map +2 -2
- package/dist/core/storage/chromadb-simple.js +17 -5
- package/dist/core/storage/chromadb-simple.js.map +2 -2
- package/dist/core/storage/infinite-storage.js +109 -46
- package/dist/core/storage/infinite-storage.js.map +2 -2
- package/dist/core/storage/railway-optimized-storage.js +48 -22
- package/dist/core/storage/railway-optimized-storage.js.map +2 -2
- package/dist/core/storage/remote-storage.js +41 -23
- package/dist/core/storage/remote-storage.js.map +2 -2
- package/dist/core/trace/cli-trace-wrapper.js +9 -2
- package/dist/core/trace/cli-trace-wrapper.js.map +2 -2
- package/dist/core/trace/db-trace-wrapper.js +96 -68
- package/dist/core/trace/db-trace-wrapper.js.map +2 -2
- package/dist/core/trace/debug-trace.js +25 -8
- package/dist/core/trace/debug-trace.js.map +2 -2
- package/dist/core/trace/index.js +6 -2
- package/dist/core/trace/index.js.map +2 -2
- package/dist/core/trace/linear-api-wrapper.js +10 -5
- package/dist/core/trace/linear-api-wrapper.js.map +2 -2
- package/dist/core/trace/trace-demo.js +14 -10
- package/dist/core/trace/trace-demo.js.map +2 -2
- package/dist/core/trace/trace-detector.js +9 -2
- package/dist/core/trace/trace-detector.js.map +2 -2
- package/dist/core/trace/types.js.map +1 -1
- package/dist/core/utils/compression.js.map +1 -1
- package/dist/core/utils/update-checker.js.map +1 -1
- package/dist/core/worktree/worktree-manager.js +18 -7
- package/dist/core/worktree/worktree-manager.js.map +2 -2
- package/dist/features/analytics/core/analytics-service.js.map +2 -2
- package/dist/features/analytics/queries/metrics-queries.js +1 -1
- package/dist/features/analytics/queries/metrics-queries.js.map +2 -2
- package/dist/features/tasks/pebbles-task-store.js.map +1 -1
- package/dist/features/tui/components/analytics-panel.js +36 -15
- package/dist/features/tui/components/analytics-panel.js.map +2 -2
- package/dist/features/tui/components/pr-tracker.js +19 -7
- package/dist/features/tui/components/pr-tracker.js.map +2 -2
- package/dist/features/tui/components/session-monitor.js +22 -9
- package/dist/features/tui/components/session-monitor.js.map +2 -2
- package/dist/features/tui/components/subagent-fleet.js +20 -13
- package/dist/features/tui/components/subagent-fleet.js.map +2 -2
- package/dist/features/tui/components/task-board.js +26 -10
- package/dist/features/tui/components/task-board.js.map +2 -2
- package/dist/features/tui/index.js.map +2 -2
- package/dist/features/tui/services/data-service.js +6 -2
- package/dist/features/tui/services/data-service.js.map +2 -2
- package/dist/features/tui/services/linear-task-reader.js +3 -1
- package/dist/features/tui/services/linear-task-reader.js.map +2 -2
- package/dist/features/tui/services/websocket-client.js +3 -1
- package/dist/features/tui/services/websocket-client.js.map +2 -2
- package/dist/features/tui/terminal-compat.js +6 -2
- package/dist/features/tui/terminal-compat.js.map +2 -2
- package/dist/features/web/client/stores/task-store.js.map +2 -2
- package/dist/features/web/server/index.js +18 -10
- package/dist/features/web/server/index.js.map +2 -2
- package/dist/integrations/linear/sync-service.js +12 -13
- package/dist/integrations/linear/sync-service.js.map +2 -2
- package/dist/integrations/linear/sync.js +174 -12
- package/dist/integrations/linear/sync.js.map +2 -2
- package/dist/integrations/linear/unified-sync.js +1 -1
- package/dist/integrations/linear/unified-sync.js.map +1 -1
- package/dist/integrations/linear/webhook-server.js +15 -16
- package/dist/integrations/linear/webhook-server.js.map +2 -2
- package/dist/mcp/stackmemory-mcp-server.js +0 -11
- package/dist/mcp/stackmemory-mcp-server.js.map +2 -2
- package/dist/servers/production/auth-middleware.js.map +2 -2
- package/dist/servers/railway/index.js.map +2 -2
- package/dist/services/config-service.js +6 -7
- package/dist/services/config-service.js.map +2 -2
- package/dist/services/context-service.js +11 -12
- package/dist/services/context-service.js.map +2 -2
- package/dist/skills/claude-skills.js +4 -2
- package/dist/skills/claude-skills.js.map +2 -2
- package/dist/skills/dashboard-launcher.js.map +2 -2
- package/dist/skills/repo-ingestion-skill.js.map +2 -2
- package/dist/utils/env.js +46 -0
- package/dist/utils/env.js.map +7 -0
- package/dist/utils/logger.js +0 -11
- package/dist/utils/logger.js.map +2 -2
- package/package.json +1 -1
|
@@ -195,18 +195,7 @@ function createConfigCommand() {
|
|
|
195
195
|
}
|
|
196
196
|
console.log(` Importance: ${color(level)}`);
|
|
197
197
|
});
|
|
198
|
-
config.command("create-profile <name>").description("Create a custom configuration profile").option(
|
|
199
|
-
"-d, --description <text>",
|
|
200
|
-
"Profile description"
|
|
201
|
-
).option(
|
|
202
|
-
"-b, --base-weight <number>",
|
|
203
|
-
"Base weight (0-1)",
|
|
204
|
-
parseFloat
|
|
205
|
-
).option(
|
|
206
|
-
"-i, --impact-weight <number>",
|
|
207
|
-
"Impact weight (0-1)",
|
|
208
|
-
parseFloat
|
|
209
|
-
).option(
|
|
198
|
+
config.command("create-profile <name>").description("Create a custom configuration profile").option("-d, --description <text>", "Profile description").option("-b, --base-weight <number>", "Base weight (0-1)", parseFloat).option("-i, --impact-weight <number>", "Impact weight (0-1)", parseFloat).option(
|
|
210
199
|
"-p, --persistence-weight <number>",
|
|
211
200
|
"Persistence weight (0-1)",
|
|
212
201
|
parseFloat
|
|
@@ -214,15 +203,14 @@ function createConfigCommand() {
|
|
|
214
203
|
"-r, --reference-weight <number>",
|
|
215
204
|
"Reference weight (0-1)",
|
|
216
205
|
parseFloat
|
|
217
|
-
).option(
|
|
218
|
-
"--copy-from <profile>",
|
|
219
|
-
"Copy settings from existing profile"
|
|
220
|
-
).action(async (name, options) => {
|
|
206
|
+
).option("--copy-from <profile>", "Copy settings from existing profile").action(async (name, options) => {
|
|
221
207
|
const manager = new ConfigManager();
|
|
222
208
|
const config2 = manager.getConfig();
|
|
223
209
|
if (config2.profiles && config2.profiles[name]) {
|
|
224
210
|
console.log(
|
|
225
|
-
chalk.yellow(
|
|
211
|
+
chalk.yellow(
|
|
212
|
+
`\u26A0 Profile '${name}' already exists. Use 'edit-profile' to modify it.`
|
|
213
|
+
)
|
|
226
214
|
);
|
|
227
215
|
process.exit(1);
|
|
228
216
|
}
|
|
@@ -230,10 +218,16 @@ function createConfigCommand() {
|
|
|
230
218
|
if (options.copyFrom) {
|
|
231
219
|
const sourceProfile = config2.profiles?.[options.copyFrom];
|
|
232
220
|
if (!sourceProfile) {
|
|
233
|
-
console.log(
|
|
221
|
+
console.log(
|
|
222
|
+
chalk.red(`\u274C Source profile '${options.copyFrom}' not found`)
|
|
223
|
+
);
|
|
234
224
|
process.exit(1);
|
|
235
225
|
}
|
|
236
|
-
newProfile = {
|
|
226
|
+
newProfile = {
|
|
227
|
+
...sourceProfile,
|
|
228
|
+
name,
|
|
229
|
+
description: options.description
|
|
230
|
+
};
|
|
237
231
|
} else {
|
|
238
232
|
const weights = {
|
|
239
233
|
base: options.baseWeight ?? DEFAULT_WEIGHTS.base,
|
|
@@ -243,7 +237,9 @@ function createConfigCommand() {
|
|
|
243
237
|
};
|
|
244
238
|
const sum = weights.base + weights.impact + weights.persistence + weights.reference;
|
|
245
239
|
if (Math.abs(sum - 1) > 1e-3) {
|
|
246
|
-
console.log(
|
|
240
|
+
console.log(
|
|
241
|
+
chalk.red(`\u274C Weights must sum to 1.0 (current: ${sum.toFixed(3)})`)
|
|
242
|
+
);
|
|
247
243
|
console.log(chalk.yellow("\nNormalizing weights to sum to 1.0..."));
|
|
248
244
|
const factor = 1 / sum;
|
|
249
245
|
weights.base *= factor;
|
|
@@ -273,17 +269,27 @@ function createConfigCommand() {
|
|
|
273
269
|
Activate with: stackmemory config set-profile ${name}`)
|
|
274
270
|
);
|
|
275
271
|
});
|
|
276
|
-
config.command("edit-profile <name>").description("Edit an existing profile").option(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
272
|
+
config.command("edit-profile <name>").description("Edit an existing profile").option(
|
|
273
|
+
"-s, --set-tool <tool:score>",
|
|
274
|
+
"Set tool score (e.g., search:0.95)",
|
|
275
|
+
(value, previous) => {
|
|
276
|
+
const result = previous || {};
|
|
277
|
+
const [tool, score] = value.split(":");
|
|
278
|
+
result[tool] = parseFloat(score);
|
|
279
|
+
return result;
|
|
280
|
+
},
|
|
281
|
+
{}
|
|
282
|
+
).option(
|
|
283
|
+
"-w, --set-weight <type:value>",
|
|
284
|
+
"Set weight (e.g., base:0.4)",
|
|
285
|
+
(value, previous) => {
|
|
286
|
+
const result = previous || {};
|
|
287
|
+
const [type, weight] = value.split(":");
|
|
288
|
+
result[type] = parseFloat(weight);
|
|
289
|
+
return result;
|
|
290
|
+
},
|
|
291
|
+
{}
|
|
292
|
+
).action(async (name, options) => {
|
|
287
293
|
const manager = new ConfigManager();
|
|
288
294
|
const config2 = manager.getConfig();
|
|
289
295
|
if (!config2.profiles?.[name]) {
|
|
@@ -312,7 +318,9 @@ Activate with: stackmemory config set-profile ${name}`)
|
|
|
312
318
|
const weights = profile.scoring.weights;
|
|
313
319
|
const sum = (weights.base || 0) + (weights.impact || 0) + (weights.persistence || 0) + (weights.reference || 0);
|
|
314
320
|
if (Math.abs(sum - 1) > 1e-3) {
|
|
315
|
-
console.log(
|
|
321
|
+
console.log(
|
|
322
|
+
chalk.yellow(`\u26A0 Weights sum to ${sum.toFixed(3)}, normalizing...`)
|
|
323
|
+
);
|
|
316
324
|
const factor = 1 / sum;
|
|
317
325
|
if (weights.base) weights.base *= factor;
|
|
318
326
|
if (weights.impact) weights.impact *= factor;
|
|
@@ -334,7 +342,9 @@ Activate with: stackmemory config set-profile ${name}`)
|
|
|
334
342
|
Profile: ${profile}`));
|
|
335
343
|
console.log("Note: Run tools with this profile to generate metrics");
|
|
336
344
|
} else {
|
|
337
|
-
console.log(
|
|
345
|
+
console.log(
|
|
346
|
+
"\nNote: Tool scoring metrics will be available after running MCP tools"
|
|
347
|
+
);
|
|
338
348
|
}
|
|
339
349
|
console.log(chalk.gray("\nMetrics tracked:"));
|
|
340
350
|
console.log(" \u2022 Average score per tool");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/config.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Config command for StackMemory CLI\n */\n\nimport { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as yaml from 'js-yaml';\nimport chalk from 'chalk';\nimport { ConfigManager } from '../../core/config/config-manager.js';\nimport { \n DEFAULT_CONFIG, \n PRESET_PROFILES, \n ProfileConfig, \n ScoringWeights,\n DEFAULT_WEIGHTS,\n DEFAULT_TOOL_SCORES\n} from '../../core/config/types.js';\n\nexport function createConfigCommand(): Command {\n const config = new Command('config').description(\n 'Manage StackMemory configuration'\n );\n\n config\n .command('validate')\n .description('Validate configuration file')\n .option(\n '-f, --file <path>',\n 'Path to config file',\n '.stackmemory/config.yaml'\n )\n .option('--fix', 'Attempt to auto-fix common issues')\n .action(async (options) => {\n console.log(chalk.blue('\uD83D\uDD0D Validating configuration...'));\n\n const configPath = path.resolve(options.file);\n const manager = new ConfigManager(configPath);\n const result = manager.validate();\n\n // Display errors\n if (result.errors.length > 0) {\n console.log(chalk.red('\\n\u2717 Errors:'));\n result.errors.forEach((error) => {\n console.log(chalk.red(` \u2022 ${error}`));\n });\n }\n\n // Display warnings\n if (result.warnings.length > 0) {\n console.log(chalk.yellow('\\n\u26A0 Warnings:'));\n result.warnings.forEach((warning) => {\n console.log(chalk.yellow(` \u2022 ${warning}`));\n });\n }\n\n // Display suggestions\n if (result.suggestions.length > 0) {\n console.log(chalk.cyan('\\n\uD83D\uDCA1 Suggestions:'));\n result.suggestions.forEach((suggestion) => {\n console.log(chalk.cyan(` \u2022 ${suggestion}`));\n });\n }\n\n // Auto-fix if requested\n if (options.fix && result.errors.length > 0) {\n console.log(chalk.blue('\\n\uD83D\uDD27 Attempting auto-fix...'));\n\n const config = manager.getConfig();\n const weights = config.scoring.weights;\n const weightSum =\n weights.base +\n weights.impact +\n weights.persistence +\n weights.reference;\n\n if (Math.abs(weightSum - 1.0) > 0.001) {\n // Normalize weights to sum to 1.0\n const factor = 1.0 / weightSum;\n manager.updateWeights({\n base: weights.base * factor,\n impact: weights.impact * factor,\n persistence: weights.persistence * factor,\n reference: weights.reference * factor,\n });\n manager.save();\n console.log(chalk.green(' \u2713 Normalized weights to sum to 1.0'));\n }\n }\n\n // Final status\n if (result.valid) {\n console.log(chalk.green('\\n\u2705 Configuration is valid'));\n process.exit(0);\n } else {\n console.log(chalk.red('\\n\u274C Configuration has errors'));\n process.exit(1);\n }\n });\n\n config\n .command('init')\n .description('Initialize configuration file with defaults')\n .option('-p, --profile <name>', 'Use a preset profile', 'default')\n .option('-f, --force', 'Overwrite existing config')\n .action(async (options) => {\n const configPath = path.join(\n process.cwd(),\n '.stackmemory',\n 'config.yaml'\n );\n\n if (fs.existsSync(configPath) && !options.force) {\n console.log(\n chalk.yellow(\n '\u26A0 Config file already exists. Use --force to overwrite.'\n )\n );\n process.exit(1);\n }\n\n const dir = path.dirname(configPath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const config = { ...DEFAULT_CONFIG };\n if (options.profile && options.profile !== 'default') {\n config.profile = options.profile;\n }\n\n const content = yaml.dump(config, {\n indent: 2,\n lineWidth: 120,\n noRefs: true,\n });\n\n fs.writeFileSync(configPath, content, 'utf-8');\n console.log(chalk.green(`\u2705 Created config file at ${configPath}`));\n\n if (options.profile !== 'default') {\n console.log(chalk.cyan(`\uD83D\uDCCB Using profile: ${options.profile}`));\n }\n });\n\n config\n .command('show')\n .description('Show current configuration')\n .option('-p, --profile <name>', 'Show specific profile')\n .action(async (options) => {\n const manager = new ConfigManager();\n const config = manager.getConfig();\n\n if (options.profile) {\n const profiles = manager.getProfiles();\n const profile = profiles[options.profile];\n\n if (!profile) {\n console.log(chalk.red(`\u274C Profile '${options.profile}' not found`));\n console.log(chalk.cyan('Available profiles:'));\n Object.keys(profiles).forEach((name) => {\n console.log(` \u2022 ${name}`);\n });\n process.exit(1);\n }\n\n console.log(chalk.blue(`\\n\uD83D\uDCCB Profile: ${profile.name}`));\n if (profile.description) {\n console.log(chalk.gray(` ${profile.description}`));\n }\n console.log('\\n' + yaml.dump(profile, { indent: 2 }));\n } else {\n console.log(chalk.blue('\\n\uD83D\uDCCB Current Configuration:'));\n if (config.profile) {\n console.log(chalk.cyan(` Active Profile: ${config.profile}`));\n }\n console.log('\\n' + yaml.dump(config, { indent: 2 }));\n }\n });\n\n config\n .command('set-profile <name>')\n .description('Set active profile')\n .action(async (name) => {\n const manager = new ConfigManager();\n\n if (manager.setProfile(name)) {\n manager.save();\n console.log(chalk.green(`\u2705 Active profile set to: ${name}`));\n } else {\n console.log(chalk.red(`\u274C Profile '${name}' not found`));\n console.log(chalk.cyan('Available profiles:'));\n Object.keys(manager.getProfiles()).forEach((profile) => {\n console.log(` \u2022 ${profile}`);\n });\n process.exit(1);\n }\n });\n\n config\n .command('list-profiles')\n .description('List available profiles')\n .action(async () => {\n const manager = new ConfigManager();\n const profiles = manager.getProfiles();\n const currentProfile = manager.getConfig().profile;\n\n console.log(chalk.blue('\\n\uD83D\uDCCB Available Profiles:'));\n Object.entries(profiles).forEach(([name, profile]) => {\n const marker = name === currentProfile ? chalk.green(' \u2713') : '';\n console.log(` \u2022 ${chalk.cyan(name)}${marker}`);\n if (profile.description) {\n console.log(chalk.gray(` ${profile.description}`));\n }\n });\n });\n\n config\n .command('test-score <tool>')\n .description('Test importance scoring for a tool')\n .option('-f, --files <number>', 'Number of files affected', parseInt)\n .option('-p, --permanent', 'Is change permanent')\n .option('-r, --references <number>', 'Reference count', parseInt)\n .action(async (tool, options) => {\n const manager = new ConfigManager();\n\n const score = manager.calculateScore(tool, {\n filesAffected: options.files,\n isPermanent: options.permanent,\n referenceCount: options.references,\n });\n\n const config = manager.getConfig();\n const baseScore = config.scoring.tool_scores[tool] || 0.5;\n\n console.log(chalk.blue('\\n\uD83D\uDCCA Score Calculation:'));\n console.log(` Tool: ${chalk.cyan(tool)}`);\n console.log(` Base Score: ${chalk.yellow(baseScore.toFixed(3))}`);\n\n if (options.files !== undefined) {\n console.log(` Files Affected: ${options.files}`);\n }\n if (options.permanent) {\n console.log(` Permanent: ${chalk.green('Yes')}`);\n }\n if (options.references !== undefined) {\n console.log(` References: ${options.references}`);\n }\n\n console.log(chalk.blue('\\n Weights:'));\n console.log(` Base: ${config.scoring.weights.base}`);\n console.log(` Impact: ${config.scoring.weights.impact}`);\n console.log(` Persistence: ${config.scoring.weights.persistence}`);\n console.log(` Reference: ${config.scoring.weights.reference}`);\n\n console.log(chalk.green(`\\n Final Score: ${score.toFixed(3)}`));\n\n // Show importance level\n let level = 'Low';\n let color = chalk.gray;\n if (score >= 0.8) {\n level = 'Critical';\n color = chalk.red;\n } else if (score >= 0.6) {\n level = 'High';\n color = chalk.yellow;\n } else if (score >= 0.4) {\n level = 'Medium';\n color = chalk.cyan;\n }\n\n console.log(` Importance: ${color(level)}`);\n });\n\n config\n .command('create-profile <name>')\n .description('Create a custom configuration profile')\n .option(\n '-d, --description <text>',\n 'Profile description'\n )\n .option(\n '-b, --base-weight <number>',\n 'Base weight (0-1)',\n parseFloat\n )\n .option(\n '-i, --impact-weight <number>',\n 'Impact weight (0-1)',\n parseFloat\n )\n .option(\n '-p, --persistence-weight <number>',\n 'Persistence weight (0-1)',\n parseFloat\n )\n .option(\n '-r, --reference-weight <number>',\n 'Reference weight (0-1)',\n parseFloat\n )\n .option(\n '--copy-from <profile>',\n 'Copy settings from existing profile'\n )\n .action(async (name, options) => {\n const manager = new ConfigManager();\n const config = manager.getConfig();\n\n // Check if profile already exists\n if (config.profiles && config.profiles[name]) {\n console.log(\n chalk.yellow(`\u26A0 Profile '${name}' already exists. Use 'edit-profile' to modify it.`)\n );\n process.exit(1);\n }\n\n let newProfile: ProfileConfig;\n\n if (options.copyFrom) {\n // Copy from existing profile\n const sourceProfile = config.profiles?.[options.copyFrom];\n if (!sourceProfile) {\n console.log(chalk.red(`\u274C Source profile '${options.copyFrom}' not found`));\n process.exit(1);\n }\n newProfile = { ...sourceProfile, name, description: options.description };\n } else {\n // Create new profile with custom weights\n const weights: ScoringWeights = {\n base: options.baseWeight ?? DEFAULT_WEIGHTS.base,\n impact: options.impactWeight ?? DEFAULT_WEIGHTS.impact,\n persistence: options.persistenceWeight ?? DEFAULT_WEIGHTS.persistence,\n reference: options.referenceWeight ?? DEFAULT_WEIGHTS.reference,\n };\n\n // Validate weights sum to 1.0\n const sum = weights.base + weights.impact + weights.persistence + weights.reference;\n if (Math.abs(sum - 1.0) > 0.001) {\n console.log(chalk.red(`\u274C Weights must sum to 1.0 (current: ${sum.toFixed(3)})`));\n console.log(chalk.yellow('\\nNormalizing weights to sum to 1.0...'));\n \n const factor = 1.0 / sum;\n weights.base *= factor;\n weights.impact *= factor;\n weights.persistence *= factor;\n weights.reference *= factor;\n }\n\n newProfile = {\n name,\n description: options.description || `Custom profile created ${new Date().toLocaleDateString()}`,\n scoring: {\n weights,\n tool_scores: DEFAULT_TOOL_SCORES,\n },\n };\n }\n\n // Add profile to config\n if (!config.profiles) {\n config.profiles = {};\n }\n config.profiles[name] = newProfile;\n\n // Save config\n manager.save();\n\n console.log(chalk.green(`\u2705 Created profile: ${name}`));\n console.log(chalk.blue('\\nProfile Configuration:'));\n console.log(yaml.dump(newProfile, { indent: 2 }));\n console.log(\n chalk.cyan(`\\nActivate with: stackmemory config set-profile ${name}`)\n );\n });\n\n config\n .command('edit-profile <name>')\n .description('Edit an existing profile')\n .option('-s, --set-tool <tool:score>', 'Set tool score (e.g., search:0.95)', (value, previous) => {\n const result = previous || {};\n const [tool, score] = value.split(':');\n result[tool] = parseFloat(score);\n return result;\n }, {})\n .option('-w, --set-weight <type:value>', 'Set weight (e.g., base:0.4)', (value, previous) => {\n const result = previous || {};\n const [type, weight] = value.split(':');\n result[type] = parseFloat(weight);\n return result;\n }, {})\n .action(async (name, options) => {\n const manager = new ConfigManager();\n const config = manager.getConfig();\n\n if (!config.profiles?.[name]) {\n console.log(chalk.red(`\u274C Profile '${name}' not found`));\n process.exit(1);\n }\n\n const profile = config.profiles[name];\n\n // Update tool scores\n if (Object.keys(options.setTool).length > 0) {\n if (!profile.scoring) {\n profile.scoring = {};\n }\n if (!profile.scoring.tool_scores) {\n profile.scoring.tool_scores = {};\n }\n Object.assign(profile.scoring.tool_scores, options.setTool);\n console.log(chalk.green('\u2713 Updated tool scores'));\n }\n\n // Update weights\n if (Object.keys(options.setWeight).length > 0) {\n if (!profile.scoring) {\n profile.scoring = {};\n }\n if (!profile.scoring.weights) {\n profile.scoring.weights = { ...DEFAULT_WEIGHTS };\n }\n Object.assign(profile.scoring.weights, options.setWeight);\n \n // Validate weights\n const weights = profile.scoring.weights;\n const sum = (weights.base || 0) + (weights.impact || 0) + \n (weights.persistence || 0) + (weights.reference || 0);\n \n if (Math.abs(sum - 1.0) > 0.001) {\n console.log(chalk.yellow(`\u26A0 Weights sum to ${sum.toFixed(3)}, normalizing...`));\n const factor = 1.0 / sum;\n if (weights.base) weights.base *= factor;\n if (weights.impact) weights.impact *= factor;\n if (weights.persistence) weights.persistence *= factor;\n if (weights.reference) weights.reference *= factor;\n }\n \n console.log(chalk.green('\u2713 Updated weights'));\n }\n\n // Save changes\n manager.save();\n\n console.log(chalk.green(`\\n\u2705 Profile '${name}' updated`));\n console.log(chalk.blue('\\nUpdated Configuration:'));\n console.log(yaml.dump(profile, { indent: 2 }));\n });\n\n config\n .command('profile-report [profile]')\n .description('Show profile effectiveness report')\n .action(async (profile) => {\n // This would integrate with the ToolScoringMiddleware\n // For now, show a placeholder\n console.log(chalk.blue('\\n\uD83D\uDCCA Profile Effectiveness Report'));\n \n if (profile) {\n console.log(chalk.cyan(`\\nProfile: ${profile}`));\n console.log('Note: Run tools with this profile to generate metrics');\n } else {\n console.log('\\nNote: Tool scoring metrics will be available after running MCP tools');\n }\n \n console.log(chalk.gray('\\nMetrics tracked:'));\n console.log(' \u2022 Average score per tool');\n console.log(' \u2022 High-importance operations');\n console.log(' \u2022 Profile usage frequency');\n console.log(' \u2022 Score trends over time');\n });\n\n return config;\n}\n"],
|
|
5
|
-
"mappings": "AAIA,SAAS,eAAe;AACxB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,OAAO,WAAW;AAClB,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,sBAA+B;AAC7C,QAAM,SAAS,IAAI,QAAQ,QAAQ,EAAE;AAAA,IACnC;AAAA,EACF;AAEA,SACG,QAAQ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IAChB,WAAW,SAAS,KAAK;AACvB,cAAQ;AACR,cAAQ,MAAM;AAAA,IAChB;AAEA,YAAQ,IAAI,iBAAiB,MAAM,KAAK,CAAC,EAAE;AAAA,EAC7C,CAAC;AAEH,SACG,QAAQ,uBAAuB,EAC/B,YAAY,uCAAuC,EACnD
|
|
4
|
+
"sourcesContent": ["/**\n * Config command for StackMemory CLI\n */\n\nimport { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as yaml from 'js-yaml';\nimport chalk from 'chalk';\nimport { ConfigManager } from '../../core/config/config-manager.js';\nimport {\n DEFAULT_CONFIG,\n PRESET_PROFILES,\n ProfileConfig,\n ScoringWeights,\n DEFAULT_WEIGHTS,\n DEFAULT_TOOL_SCORES,\n} from '../../core/config/types.js';\n\nexport function createConfigCommand(): Command {\n const config = new Command('config').description(\n 'Manage StackMemory configuration'\n );\n\n config\n .command('validate')\n .description('Validate configuration file')\n .option(\n '-f, --file <path>',\n 'Path to config file',\n '.stackmemory/config.yaml'\n )\n .option('--fix', 'Attempt to auto-fix common issues')\n .action(async (options) => {\n console.log(chalk.blue('\uD83D\uDD0D Validating configuration...'));\n\n const configPath = path.resolve(options.file);\n const manager = new ConfigManager(configPath);\n const result = manager.validate();\n\n // Display errors\n if (result.errors.length > 0) {\n console.log(chalk.red('\\n\u2717 Errors:'));\n result.errors.forEach((error) => {\n console.log(chalk.red(` \u2022 ${error}`));\n });\n }\n\n // Display warnings\n if (result.warnings.length > 0) {\n console.log(chalk.yellow('\\n\u26A0 Warnings:'));\n result.warnings.forEach((warning) => {\n console.log(chalk.yellow(` \u2022 ${warning}`));\n });\n }\n\n // Display suggestions\n if (result.suggestions.length > 0) {\n console.log(chalk.cyan('\\n\uD83D\uDCA1 Suggestions:'));\n result.suggestions.forEach((suggestion) => {\n console.log(chalk.cyan(` \u2022 ${suggestion}`));\n });\n }\n\n // Auto-fix if requested\n if (options.fix && result.errors.length > 0) {\n console.log(chalk.blue('\\n\uD83D\uDD27 Attempting auto-fix...'));\n\n const config = manager.getConfig();\n const weights = config.scoring.weights;\n const weightSum =\n weights.base +\n weights.impact +\n weights.persistence +\n weights.reference;\n\n if (Math.abs(weightSum - 1.0) > 0.001) {\n // Normalize weights to sum to 1.0\n const factor = 1.0 / weightSum;\n manager.updateWeights({\n base: weights.base * factor,\n impact: weights.impact * factor,\n persistence: weights.persistence * factor,\n reference: weights.reference * factor,\n });\n manager.save();\n console.log(chalk.green(' \u2713 Normalized weights to sum to 1.0'));\n }\n }\n\n // Final status\n if (result.valid) {\n console.log(chalk.green('\\n\u2705 Configuration is valid'));\n process.exit(0);\n } else {\n console.log(chalk.red('\\n\u274C Configuration has errors'));\n process.exit(1);\n }\n });\n\n config\n .command('init')\n .description('Initialize configuration file with defaults')\n .option('-p, --profile <name>', 'Use a preset profile', 'default')\n .option('-f, --force', 'Overwrite existing config')\n .action(async (options) => {\n const configPath = path.join(\n process.cwd(),\n '.stackmemory',\n 'config.yaml'\n );\n\n if (fs.existsSync(configPath) && !options.force) {\n console.log(\n chalk.yellow(\n '\u26A0 Config file already exists. Use --force to overwrite.'\n )\n );\n process.exit(1);\n }\n\n const dir = path.dirname(configPath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const config = { ...DEFAULT_CONFIG };\n if (options.profile && options.profile !== 'default') {\n config.profile = options.profile;\n }\n\n const content = yaml.dump(config, {\n indent: 2,\n lineWidth: 120,\n noRefs: true,\n });\n\n fs.writeFileSync(configPath, content, 'utf-8');\n console.log(chalk.green(`\u2705 Created config file at ${configPath}`));\n\n if (options.profile !== 'default') {\n console.log(chalk.cyan(`\uD83D\uDCCB Using profile: ${options.profile}`));\n }\n });\n\n config\n .command('show')\n .description('Show current configuration')\n .option('-p, --profile <name>', 'Show specific profile')\n .action(async (options) => {\n const manager = new ConfigManager();\n const config = manager.getConfig();\n\n if (options.profile) {\n const profiles = manager.getProfiles();\n const profile = profiles[options.profile];\n\n if (!profile) {\n console.log(chalk.red(`\u274C Profile '${options.profile}' not found`));\n console.log(chalk.cyan('Available profiles:'));\n Object.keys(profiles).forEach((name) => {\n console.log(` \u2022 ${name}`);\n });\n process.exit(1);\n }\n\n console.log(chalk.blue(`\\n\uD83D\uDCCB Profile: ${profile.name}`));\n if (profile.description) {\n console.log(chalk.gray(` ${profile.description}`));\n }\n console.log('\\n' + yaml.dump(profile, { indent: 2 }));\n } else {\n console.log(chalk.blue('\\n\uD83D\uDCCB Current Configuration:'));\n if (config.profile) {\n console.log(chalk.cyan(` Active Profile: ${config.profile}`));\n }\n console.log('\\n' + yaml.dump(config, { indent: 2 }));\n }\n });\n\n config\n .command('set-profile <name>')\n .description('Set active profile')\n .action(async (name) => {\n const manager = new ConfigManager();\n\n if (manager.setProfile(name)) {\n manager.save();\n console.log(chalk.green(`\u2705 Active profile set to: ${name}`));\n } else {\n console.log(chalk.red(`\u274C Profile '${name}' not found`));\n console.log(chalk.cyan('Available profiles:'));\n Object.keys(manager.getProfiles()).forEach((profile) => {\n console.log(` \u2022 ${profile}`);\n });\n process.exit(1);\n }\n });\n\n config\n .command('list-profiles')\n .description('List available profiles')\n .action(async () => {\n const manager = new ConfigManager();\n const profiles = manager.getProfiles();\n const currentProfile = manager.getConfig().profile;\n\n console.log(chalk.blue('\\n\uD83D\uDCCB Available Profiles:'));\n Object.entries(profiles).forEach(([name, profile]) => {\n const marker = name === currentProfile ? chalk.green(' \u2713') : '';\n console.log(` \u2022 ${chalk.cyan(name)}${marker}`);\n if (profile.description) {\n console.log(chalk.gray(` ${profile.description}`));\n }\n });\n });\n\n config\n .command('test-score <tool>')\n .description('Test importance scoring for a tool')\n .option('-f, --files <number>', 'Number of files affected', parseInt)\n .option('-p, --permanent', 'Is change permanent')\n .option('-r, --references <number>', 'Reference count', parseInt)\n .action(async (tool, options) => {\n const manager = new ConfigManager();\n\n const score = manager.calculateScore(tool, {\n filesAffected: options.files,\n isPermanent: options.permanent,\n referenceCount: options.references,\n });\n\n const config = manager.getConfig();\n const baseScore = config.scoring.tool_scores[tool] || 0.5;\n\n console.log(chalk.blue('\\n\uD83D\uDCCA Score Calculation:'));\n console.log(` Tool: ${chalk.cyan(tool)}`);\n console.log(` Base Score: ${chalk.yellow(baseScore.toFixed(3))}`);\n\n if (options.files !== undefined) {\n console.log(` Files Affected: ${options.files}`);\n }\n if (options.permanent) {\n console.log(` Permanent: ${chalk.green('Yes')}`);\n }\n if (options.references !== undefined) {\n console.log(` References: ${options.references}`);\n }\n\n console.log(chalk.blue('\\n Weights:'));\n console.log(` Base: ${config.scoring.weights.base}`);\n console.log(` Impact: ${config.scoring.weights.impact}`);\n console.log(` Persistence: ${config.scoring.weights.persistence}`);\n console.log(` Reference: ${config.scoring.weights.reference}`);\n\n console.log(chalk.green(`\\n Final Score: ${score.toFixed(3)}`));\n\n // Show importance level\n let level = 'Low';\n let color = chalk.gray;\n if (score >= 0.8) {\n level = 'Critical';\n color = chalk.red;\n } else if (score >= 0.6) {\n level = 'High';\n color = chalk.yellow;\n } else if (score >= 0.4) {\n level = 'Medium';\n color = chalk.cyan;\n }\n\n console.log(` Importance: ${color(level)}`);\n });\n\n config\n .command('create-profile <name>')\n .description('Create a custom configuration profile')\n .option('-d, --description <text>', 'Profile description')\n .option('-b, --base-weight <number>', 'Base weight (0-1)', parseFloat)\n .option('-i, --impact-weight <number>', 'Impact weight (0-1)', parseFloat)\n .option(\n '-p, --persistence-weight <number>',\n 'Persistence weight (0-1)',\n parseFloat\n )\n .option(\n '-r, --reference-weight <number>',\n 'Reference weight (0-1)',\n parseFloat\n )\n .option('--copy-from <profile>', 'Copy settings from existing profile')\n .action(async (name, options) => {\n const manager = new ConfigManager();\n const config = manager.getConfig();\n\n // Check if profile already exists\n if (config.profiles && config.profiles[name]) {\n console.log(\n chalk.yellow(\n `\u26A0 Profile '${name}' already exists. Use 'edit-profile' to modify it.`\n )\n );\n process.exit(1);\n }\n\n let newProfile: ProfileConfig;\n\n if (options.copyFrom) {\n // Copy from existing profile\n const sourceProfile = config.profiles?.[options.copyFrom];\n if (!sourceProfile) {\n console.log(\n chalk.red(`\u274C Source profile '${options.copyFrom}' not found`)\n );\n process.exit(1);\n }\n newProfile = {\n ...sourceProfile,\n name,\n description: options.description,\n };\n } else {\n // Create new profile with custom weights\n const weights: ScoringWeights = {\n base: options.baseWeight ?? DEFAULT_WEIGHTS.base,\n impact: options.impactWeight ?? DEFAULT_WEIGHTS.impact,\n persistence: options.persistenceWeight ?? DEFAULT_WEIGHTS.persistence,\n reference: options.referenceWeight ?? DEFAULT_WEIGHTS.reference,\n };\n\n // Validate weights sum to 1.0\n const sum =\n weights.base +\n weights.impact +\n weights.persistence +\n weights.reference;\n if (Math.abs(sum - 1.0) > 0.001) {\n console.log(\n chalk.red(`\u274C Weights must sum to 1.0 (current: ${sum.toFixed(3)})`)\n );\n console.log(chalk.yellow('\\nNormalizing weights to sum to 1.0...'));\n\n const factor = 1.0 / sum;\n weights.base *= factor;\n weights.impact *= factor;\n weights.persistence *= factor;\n weights.reference *= factor;\n }\n\n newProfile = {\n name,\n description:\n options.description ||\n `Custom profile created ${new Date().toLocaleDateString()}`,\n scoring: {\n weights,\n tool_scores: DEFAULT_TOOL_SCORES,\n },\n };\n }\n\n // Add profile to config\n if (!config.profiles) {\n config.profiles = {};\n }\n config.profiles[name] = newProfile;\n\n // Save config\n manager.save();\n\n console.log(chalk.green(`\u2705 Created profile: ${name}`));\n console.log(chalk.blue('\\nProfile Configuration:'));\n console.log(yaml.dump(newProfile, { indent: 2 }));\n console.log(\n chalk.cyan(`\\nActivate with: stackmemory config set-profile ${name}`)\n );\n });\n\n config\n .command('edit-profile <name>')\n .description('Edit an existing profile')\n .option(\n '-s, --set-tool <tool:score>',\n 'Set tool score (e.g., search:0.95)',\n (value, previous) => {\n const result = previous || {};\n const [tool, score] = value.split(':');\n result[tool] = parseFloat(score);\n return result;\n },\n {}\n )\n .option(\n '-w, --set-weight <type:value>',\n 'Set weight (e.g., base:0.4)',\n (value, previous) => {\n const result = previous || {};\n const [type, weight] = value.split(':');\n result[type] = parseFloat(weight);\n return result;\n },\n {}\n )\n .action(async (name, options) => {\n const manager = new ConfigManager();\n const config = manager.getConfig();\n\n if (!config.profiles?.[name]) {\n console.log(chalk.red(`\u274C Profile '${name}' not found`));\n process.exit(1);\n }\n\n const profile = config.profiles[name];\n\n // Update tool scores\n if (Object.keys(options.setTool).length > 0) {\n if (!profile.scoring) {\n profile.scoring = {};\n }\n if (!profile.scoring.tool_scores) {\n profile.scoring.tool_scores = {};\n }\n Object.assign(profile.scoring.tool_scores, options.setTool);\n console.log(chalk.green('\u2713 Updated tool scores'));\n }\n\n // Update weights\n if (Object.keys(options.setWeight).length > 0) {\n if (!profile.scoring) {\n profile.scoring = {};\n }\n if (!profile.scoring.weights) {\n profile.scoring.weights = { ...DEFAULT_WEIGHTS };\n }\n Object.assign(profile.scoring.weights, options.setWeight);\n\n // Validate weights\n const weights = profile.scoring.weights;\n const sum =\n (weights.base || 0) +\n (weights.impact || 0) +\n (weights.persistence || 0) +\n (weights.reference || 0);\n\n if (Math.abs(sum - 1.0) > 0.001) {\n console.log(\n chalk.yellow(`\u26A0 Weights sum to ${sum.toFixed(3)}, normalizing...`)\n );\n const factor = 1.0 / sum;\n if (weights.base) weights.base *= factor;\n if (weights.impact) weights.impact *= factor;\n if (weights.persistence) weights.persistence *= factor;\n if (weights.reference) weights.reference *= factor;\n }\n\n console.log(chalk.green('\u2713 Updated weights'));\n }\n\n // Save changes\n manager.save();\n\n console.log(chalk.green(`\\n\u2705 Profile '${name}' updated`));\n console.log(chalk.blue('\\nUpdated Configuration:'));\n console.log(yaml.dump(profile, { indent: 2 }));\n });\n\n config\n .command('profile-report [profile]')\n .description('Show profile effectiveness report')\n .action(async (profile) => {\n // This would integrate with the ToolScoringMiddleware\n // For now, show a placeholder\n console.log(chalk.blue('\\n\uD83D\uDCCA Profile Effectiveness Report'));\n\n if (profile) {\n console.log(chalk.cyan(`\\nProfile: ${profile}`));\n console.log('Note: Run tools with this profile to generate metrics');\n } else {\n console.log(\n '\\nNote: Tool scoring metrics will be available after running MCP tools'\n );\n }\n\n console.log(chalk.gray('\\nMetrics tracked:'));\n console.log(' \u2022 Average score per tool');\n console.log(' \u2022 High-importance operations');\n console.log(' \u2022 Profile usage frequency');\n console.log(' \u2022 Score trends over time');\n });\n\n return config;\n}\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,eAAe;AACxB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,OAAO,WAAW;AAClB,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,sBAA+B;AAC7C,QAAM,SAAS,IAAI,QAAQ,QAAQ,EAAE;AAAA,IACnC;AAAA,EACF;AAEA,SACG,QAAQ,UAAU,EAClB,YAAY,6BAA6B,EACzC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC,OAAO,SAAS,mCAAmC,EACnD,OAAO,OAAO,YAAY;AACzB,YAAQ,IAAI,MAAM,KAAK,uCAAgC,CAAC;AAExD,UAAM,aAAa,KAAK,QAAQ,QAAQ,IAAI;AAC5C,UAAM,UAAU,IAAI,cAAc,UAAU;AAC5C,UAAM,SAAS,QAAQ,SAAS;AAGhC,QAAI,OAAO,OAAO,SAAS,GAAG;AAC5B,cAAQ,IAAI,MAAM,IAAI,kBAAa,CAAC;AACpC,aAAO,OAAO,QAAQ,CAAC,UAAU;AAC/B,gBAAQ,IAAI,MAAM,IAAI,YAAO,KAAK,EAAE,CAAC;AAAA,MACvC,CAAC;AAAA,IACH;AAGA,QAAI,OAAO,SAAS,SAAS,GAAG;AAC9B,cAAQ,IAAI,MAAM,OAAO,oBAAe,CAAC;AACzC,aAAO,SAAS,QAAQ,CAAC,YAAY;AACnC,gBAAQ,IAAI,MAAM,OAAO,YAAO,OAAO,EAAE,CAAC;AAAA,MAC5C,CAAC;AAAA,IACH;AAGA,QAAI,OAAO,YAAY,SA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C;AAC/C,cAAQ,IAAI,uDAAuD;AAAA,IACrE,OAAO;AACL,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAI,MAAM,KAAK,oBAAoB,CAAC;AAC5C,YAAQ,IAAI,iCAA4B;AACxC,YAAQ,IAAI,qCAAgC;AAC5C,YAAQ,IAAI,kCAA6B;AACzC,YAAQ,IAAI,iCAA4B;AAAA,EAC1C,CAAC;AAEH,SAAO;AACT;",
|
|
6
6
|
"names": ["config"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/context.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Context Commands for StackMemory CLI\n * Manage context stack (show, push, pop)\n */\n\nimport { Command } from 'commander';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport { FrameManager, FrameType } from '../../core/context/frame-manager.js';\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\n\nexport function createContextCommands(): Command {\n const context = new Command('context')\n .alias('ctx')\n .description('Manage context stack');\n\n // Show current context\n context\n .command('show')\n .alias('status')\n .description('Show current context stack')\n .option('-v, --verbose', 'Show detailed information')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n // Get project ID - try metadata table, fallback to default\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(\n `\n SELECT value FROM metadata WHERE key = 'project_id'\n `\n )\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {\n // metadata table doesn't exist, use default\n }\n\n const frameManager = new FrameManager(db, projectId, { \n skipContextBridge: true \n });\n\n const depth = frameManager.getStackDepth();\n const activePath = frameManager.getActiveFramePath();\n\n console.log(`\\n\uD83D\uDCDA Context Stack\\n`);\n console.log(`Project: ${projectId}`);\n console.log(`Depth: ${depth}`);\n console.log(`Active frames: ${activePath.length}\\n`);\n\n if (activePath.length === 0) {\n console.log('No active context frames.\\n');\n console.log('Use \"stackmemory context push\" to create one.');\n } else {\n const typeIcon: Record<string, string> = {\n session: '\uD83D\uDD37',\n task: '\uD83D\uDCCB',\n command: '\u26A1',\n file: '\uD83D\uDCC4',\n decision: '\uD83D\uDCA1',\n };\n\n console.log('Stack (bottom to top):');\n activePath.forEach((frame, i) => {\n const icon = typeIcon[frame.type] || '\uD83D\uDCE6';\n const indent = ' '.repeat(i);\n console.log(\n `${indent}${i === activePath.length - 1 ? '\u2514\u2500' : '\u251C\u2500'} ${icon} ${frame.name || frame.frame_id.slice(0, 10)}`\n );\n\n if (options.verbose) {\n console.log(`${indent} ID: ${frame.frame_id}`);\n console.log(`${indent} Type: ${frame.type}`);\n console.log(\n `${indent} Created: ${new Date(frame.created_at * 1000).toLocaleString()}`\n );\n }\n });\n }\n\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to show context:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Push new context frame\n context\n .command('push <name>')\n .description('Push a new context frame onto the stack')\n .option(\n '-t, --type <type>',\n 'Frame type (session, task, command, file, decision)',\n 'task'\n )\n .option('-m, --metadata <json>', 'Additional metadata as JSON')\n .action(async (name, options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, { \n skipContextBridge: true \n });\n\n // Get current top frame as parent\n const activePath = frameManager.getActiveFramePath();\n const parentId =\n activePath.length > 0\n ? activePath[activePath.length - 1].frame_id\n : undefined;\n\n // Parse metadata if provided\n let inputs = {};\n if (options.metadata) {\n try {\n inputs = JSON.parse(options.metadata);\n } catch {\n console.log('\u26A0\uFE0F Invalid metadata JSON, ignoring');\n }\n }\n\n const frameId = frameManager.createFrame({\n type: options.type as FrameType,\n name,\n inputs,\n parentFrameId: parentId,\n });\n\n console.log(`\u2705 Pushed context frame: ${name}`);\n console.log(` ID: ${frameId.slice(0, 10)}`);\n console.log(` Type: ${options.type}`);\n console.log(` Depth: ${frameManager.getStackDepth()}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to push context:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Pop context frame\n context\n .command('pop')\n .description('Pop the top context frame from the stack')\n .option('-a, --all', 'Pop all frames (clear stack)')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, { \n skipContextBridge: true \n });\n\n const activePath = frameManager.getActiveFramePath();\n\n if (activePath.length === 0) {\n console.log('\uD83D\uDCDA Stack is already empty.');\n return;\n }\n\n if (options.all) {\n // Close all frames from top to bottom\n for (let i = activePath.length - 1; i >= 0; i--) {\n frameManager.closeFrame(activePath[i].frame_id);\n }\n console.log(`\u2705 Cleared all ${activePath.length} context frames.`);\n } else {\n // Close just the top frame\n const topFrame = activePath[activePath.length - 1];\n frameManager.closeFrame(topFrame.frame_id);\n console.log(\n `\u2705 Popped: ${topFrame.name || topFrame.frame_id.slice(0, 10)}`\n );\n console.log(` Depth: ${frameManager.getStackDepth()}`);\n }\n } catch (error: unknown) {\n console.error('\u274C Failed to pop context:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Add event to current context\n context\n .command('add <type> <message>')\n .description(\n 'Add an event to current context (types: observation, decision, error)'\n )\n .action(async (type, message) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, { \n skipContextBridge: true \n });\n\n const activePath = frameManager.getActiveFramePath();\n\n if (activePath.length === 0) {\n console.log('\u26A0\uFE0F No active context frame. Creating one...');\n frameManager.createFrame({\n type: 'task',\n name: 'cli-session',\n inputs: {},\n });\n }\n\n const currentFrame = frameManager.getActiveFramePath().slice(-1)[0];\n\n const validTypes = [\n 'observation',\n 'decision',\n 'error',\n 'action',\n 'result',\n ];\n if (!validTypes.includes(type)) {\n console.log(`\u26A0\uFE0F Unknown event type \"${type}\". Using \"observation\".`);\n type = 'observation';\n }\n\n frameManager.addEvent(\n type,\n { message, content: message },\n currentFrame.frame_id\n );\n\n console.log(\n `\u2705 Added ${type}: ${message.slice(0, 50)}${message.length > 50 ? '...' : ''}`\n );\n } catch (error: unknown) {\n console.error('\u274C Failed to add event:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Worktree integration commands\n context\n .command('worktree [action]')\n .description('Manage Claude worktree contexts')\n .option('-i, --instance <id>', 'Instance ID')\n .option('-b, --branch <name>', 'Branch name')\n .option('-l, --list', 'List worktree contexts')\n .action(async (action, options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, { \n skipContextBridge: true \n });\n\n if (options.list || action === 'list') {\n // List all worktree contexts\n const worktreeFrames = db\n .prepare(\n `\n SELECT * FROM frames \n WHERE project_id = ? \n AND type = 'session' \n AND inputs LIKE '%worktree%'\n ORDER BY created_at DESC\n LIMIT 10\n `\n )\n .all(projectId) as any[];\n\n console.log('\\n\uD83C\uDF33 Worktree Contexts\\n');\n if (worktreeFrames.length === 0) {\n console.log('No worktree contexts found.');\n } else {\n worktreeFrames.forEach((frame) => {\n const inputs = JSON.parse(frame.inputs || '{}');\n const instanceId = inputs.instanceId || 'unknown';\n const branch = inputs.branch || 'unknown';\n const created = new Date(\n frame.created_at * 1000\n ).toLocaleString();\n console.log(`\uD83D\uDCCD ${frame.name || frame.frame_id.slice(0, 10)}`);\n console.log(` Instance: ${instanceId}`);\n console.log(` Branch: ${branch}`);\n console.log(` Created: ${created}`);\n console.log('');\n });\n }\n } else if (action === 'save') {\n // Save current worktree context\n const instanceId = options.instance || process.env['CLAUDE_INSTANCE_ID'];\n const branch = options.branch || 'unknown';\n\n if (!instanceId) {\n console.log('\u26A0\uFE0F No instance ID provided or detected.');\n return;\n }\n\n const frameId = frameManager.createFrame({\n type: 'task',\n name: `worktree-${branch}`,\n inputs: {\n worktree: true,\n instanceId,\n branch,\n path: process.cwd(),\n },\n });\n\n console.log(`\u2705 Saved worktree context for ${branch}`);\n console.log(` Instance: ${instanceId}`);\n console.log(` Frame ID: ${frameId.slice(0, 10)}`);\n } else if (action === 'load') {\n // Load worktree context\n const instanceId = options.instance || process.env['CLAUDE_INSTANCE_ID'];\n\n if (!instanceId) {\n console.log('\u26A0\uFE0F No instance ID provided.');\n return;\n }\n\n const worktreeFrame = db\n .prepare(\n `\n SELECT * FROM frames \n WHERE project_id = ? \n AND type = 'session' \n AND inputs LIKE ?\n ORDER BY created_at DESC\n LIMIT 1\n `\n )\n .get(projectId, `%\"instanceId\":\"${instanceId}\"%`) as any;\n\n if (worktreeFrame) {\n const inputs = JSON.parse(worktreeFrame.inputs || '{}');\n console.log(`\u2705 Loaded worktree context`);\n console.log(` Branch: ${inputs.branch}`);\n console.log(` Instance: ${inputs.instanceId}`);\n console.log(` Path: ${inputs.path}`);\n } else {\n console.log('\u26A0\uFE0F No worktree context found for this instance.');\n }\n } else {\n console.log('Usage: stackmemory context worktree [save|load|list]');\n }\n } catch (error: unknown) {\n console.error(\n '\u274C Failed to manage worktree context:',\n (error as Error).message\n );\n } finally {\n db.close();\n }\n });\n\n return context;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,oBAA+B;AAExC,SAAS,OAAO,KAAa,cAA+B;AAC1D,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,UAAU,QAAW;AACvB,QAAI,iBAAiB,OAAW,QAAO;AACvC,UAAM,IAAI,MAAM,wBAAwB,GAAG,cAAc;AAAA,EAC3D;AACA,SAAO;AACT;AAEA,SAAS,eAAe,KAAiC;AACvD,SAAO,QAAQ,IAAI,GAAG;AACxB;
|
|
4
|
+
"sourcesContent": ["/**\n * Context Commands for StackMemory CLI\n * Manage context stack (show, push, pop)\n */\n\nimport { Command } from 'commander';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\nimport { FrameManager, FrameType } from '../../core/context/frame-manager.js';\n// Type-safe environment variable access\nfunction getEnv(key: string, defaultValue?: string): string {\n const value = process.env[key];\n if (value === undefined) {\n if (defaultValue !== undefined) return defaultValue;\n throw new Error(`Environment variable ${key} is required`);\n }\n return value;\n}\n\nfunction getOptionalEnv(key: string): string | undefined {\n return process.env[key];\n}\n\nexport function createContextCommands(): Command {\n const context = new Command('context')\n .alias('ctx')\n .description('Manage context stack');\n\n // Show current context\n context\n .command('show')\n .alias('status')\n .description('Show current context stack')\n .option('-v, --verbose', 'Show detailed information')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n // Get project ID - try metadata table, fallback to default\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(\n `\n SELECT value FROM metadata WHERE key = 'project_id'\n `\n )\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {\n // metadata table doesn't exist, use default\n }\n\n const frameManager = new FrameManager(db, projectId, {\n skipContextBridge: true,\n });\n\n const depth = frameManager.getStackDepth();\n const activePath = frameManager.getActiveFramePath();\n\n console.log(`\\n\uD83D\uDCDA Context Stack\\n`);\n console.log(`Project: ${projectId}`);\n console.log(`Depth: ${depth}`);\n console.log(`Active frames: ${activePath.length}\\n`);\n\n if (activePath.length === 0) {\n console.log('No active context frames.\\n');\n console.log('Use \"stackmemory context push\" to create one.');\n } else {\n const typeIcon: Record<string, string> = {\n session: '\uD83D\uDD37',\n task: '\uD83D\uDCCB',\n command: '\u26A1',\n file: '\uD83D\uDCC4',\n decision: '\uD83D\uDCA1',\n };\n\n console.log('Stack (bottom to top):');\n activePath.forEach((frame, i) => {\n const icon = typeIcon[frame.type] || '\uD83D\uDCE6';\n const indent = ' '.repeat(i);\n console.log(\n `${indent}${i === activePath.length - 1 ? '\u2514\u2500' : '\u251C\u2500'} ${icon} ${frame.name || frame.frame_id.slice(0, 10)}`\n );\n\n if (options.verbose) {\n console.log(`${indent} ID: ${frame.frame_id}`);\n console.log(`${indent} Type: ${frame.type}`);\n console.log(\n `${indent} Created: ${new Date(frame.created_at * 1000).toLocaleString()}`\n );\n }\n });\n }\n\n console.log('');\n } catch (error: unknown) {\n console.error('\u274C Failed to show context:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Push new context frame\n context\n .command('push <name>')\n .description('Push a new context frame onto the stack')\n .option(\n '-t, --type <type>',\n 'Frame type (session, task, command, file, decision)',\n 'task'\n )\n .option('-m, --metadata <json>', 'Additional metadata as JSON')\n .action(async (name, options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, {\n skipContextBridge: true,\n });\n\n // Get current top frame as parent\n const activePath = frameManager.getActiveFramePath();\n const parentId =\n activePath.length > 0\n ? activePath[activePath.length - 1].frame_id\n : undefined;\n\n // Parse metadata if provided\n let inputs = {};\n if (options.metadata) {\n try {\n inputs = JSON.parse(options.metadata);\n } catch {\n console.log('\u26A0\uFE0F Invalid metadata JSON, ignoring');\n }\n }\n\n const frameId = frameManager.createFrame({\n type: options.type as FrameType,\n name,\n inputs,\n parentFrameId: parentId,\n });\n\n console.log(`\u2705 Pushed context frame: ${name}`);\n console.log(` ID: ${frameId.slice(0, 10)}`);\n console.log(` Type: ${options.type}`);\n console.log(` Depth: ${frameManager.getStackDepth()}`);\n } catch (error: unknown) {\n console.error('\u274C Failed to push context:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Pop context frame\n context\n .command('pop')\n .description('Pop the top context frame from the stack')\n .option('-a, --all', 'Pop all frames (clear stack)')\n .action(async (options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, {\n skipContextBridge: true,\n });\n\n const activePath = frameManager.getActiveFramePath();\n\n if (activePath.length === 0) {\n console.log('\uD83D\uDCDA Stack is already empty.');\n return;\n }\n\n if (options.all) {\n // Close all frames from top to bottom\n for (let i = activePath.length - 1; i >= 0; i--) {\n frameManager.closeFrame(activePath[i].frame_id);\n }\n console.log(`\u2705 Cleared all ${activePath.length} context frames.`);\n } else {\n // Close just the top frame\n const topFrame = activePath[activePath.length - 1];\n frameManager.closeFrame(topFrame.frame_id);\n console.log(\n `\u2705 Popped: ${topFrame.name || topFrame.frame_id.slice(0, 10)}`\n );\n console.log(` Depth: ${frameManager.getStackDepth()}`);\n }\n } catch (error: unknown) {\n console.error('\u274C Failed to pop context:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Add event to current context\n context\n .command('add <type> <message>')\n .description(\n 'Add an event to current context (types: observation, decision, error)'\n )\n .action(async (type, message) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, {\n skipContextBridge: true,\n });\n\n const activePath = frameManager.getActiveFramePath();\n\n if (activePath.length === 0) {\n console.log('\u26A0\uFE0F No active context frame. Creating one...');\n frameManager.createFrame({\n type: 'task',\n name: 'cli-session',\n inputs: {},\n });\n }\n\n const currentFrame = frameManager.getActiveFramePath().slice(-1)[0];\n\n const validTypes = [\n 'observation',\n 'decision',\n 'error',\n 'action',\n 'result',\n ];\n if (!validTypes.includes(type)) {\n console.log(`\u26A0\uFE0F Unknown event type \"${type}\". Using \"observation\".`);\n type = 'observation';\n }\n\n frameManager.addEvent(\n type,\n { message, content: message },\n currentFrame.frame_id\n );\n\n console.log(\n `\u2705 Added ${type}: ${message.slice(0, 50)}${message.length > 50 ? '...' : ''}`\n );\n } catch (error: unknown) {\n console.error('\u274C Failed to add event:', (error as Error).message);\n } finally {\n db.close();\n }\n });\n\n // Worktree integration commands\n context\n .command('worktree [action]')\n .description('Manage Claude worktree contexts')\n .option('-i, --instance <id>', 'Instance ID')\n .option('-b, --branch <name>', 'Branch name')\n .option('-l, --list', 'List worktree contexts')\n .action(async (action, options) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const db = new Database(dbPath);\n\n try {\n let projectId = 'default';\n try {\n const projectRow = db\n .prepare(`SELECT value FROM metadata WHERE key = 'project_id'`)\n .get() as any;\n if (projectRow?.value) projectId = projectRow.value;\n } catch {}\n\n const frameManager = new FrameManager(db, projectId, {\n skipContextBridge: true,\n });\n\n if (options.list || action === 'list') {\n // List all worktree contexts\n const worktreeFrames = db\n .prepare(\n `\n SELECT * FROM frames \n WHERE project_id = ? \n AND type = 'session' \n AND inputs LIKE '%worktree%'\n ORDER BY created_at DESC\n LIMIT 10\n `\n )\n .all(projectId) as any[];\n\n console.log('\\n\uD83C\uDF33 Worktree Contexts\\n');\n if (worktreeFrames.length === 0) {\n console.log('No worktree contexts found.');\n } else {\n worktreeFrames.forEach((frame) => {\n const inputs = JSON.parse(frame.inputs || '{}');\n const instanceId = inputs.instanceId || 'unknown';\n const branch = inputs.branch || 'unknown';\n const created = new Date(\n frame.created_at * 1000\n ).toLocaleString();\n console.log(`\uD83D\uDCCD ${frame.name || frame.frame_id.slice(0, 10)}`);\n console.log(` Instance: ${instanceId}`);\n console.log(` Branch: ${branch}`);\n console.log(` Created: ${created}`);\n console.log('');\n });\n }\n } else if (action === 'save') {\n // Save current worktree context\n const instanceId =\n options.instance || process.env['CLAUDE_INSTANCE_ID'];\n const branch = options.branch || 'unknown';\n\n if (!instanceId) {\n console.log('\u26A0\uFE0F No instance ID provided or detected.');\n return;\n }\n\n const frameId = frameManager.createFrame({\n type: 'task',\n name: `worktree-${branch}`,\n inputs: {\n worktree: true,\n instanceId,\n branch,\n path: process.cwd(),\n },\n });\n\n console.log(`\u2705 Saved worktree context for ${branch}`);\n console.log(` Instance: ${instanceId}`);\n console.log(` Frame ID: ${frameId.slice(0, 10)}`);\n } else if (action === 'load') {\n // Load worktree context\n const instanceId =\n options.instance || process.env['CLAUDE_INSTANCE_ID'];\n\n if (!instanceId) {\n console.log('\u26A0\uFE0F No instance ID provided.');\n return;\n }\n\n const worktreeFrame = db\n .prepare(\n `\n SELECT * FROM frames \n WHERE project_id = ? \n AND type = 'session' \n AND inputs LIKE ?\n ORDER BY created_at DESC\n LIMIT 1\n `\n )\n .get(projectId, `%\"instanceId\":\"${instanceId}\"%`) as any;\n\n if (worktreeFrame) {\n const inputs = JSON.parse(worktreeFrame.inputs || '{}');\n console.log(`\u2705 Loaded worktree context`);\n console.log(` Branch: ${inputs.branch}`);\n console.log(` Instance: ${inputs.instanceId}`);\n console.log(` Path: ${inputs.path}`);\n } else {\n console.log('\u26A0\uFE0F No worktree context found for this instance.');\n }\n } else {\n console.log('Usage: stackmemory context worktree [save|load|list]');\n }\n } catch (error: unknown) {\n console.error(\n '\u274C Failed to manage wor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D;AAAA,MACpE;AAAA,IACF,SAAS,OAAgB;AACvB,cAAQ;AAAA,QACN;AAAA,QACC,MAAgB;AAAA,MACnB;AAAA,IACF,UAAE;AACA,SAAG,MAAM;AAAA,IACX;AAAA,EACF,CAAC;AAEH,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,14 +25,28 @@ const dashboardCommand = {
|
|
|
25
25
|
const projectRoot = process.cwd();
|
|
26
26
|
const dbPath = join(projectRoot, ".stackmemory", "context.db");
|
|
27
27
|
if (!existsSync(dbPath)) {
|
|
28
|
-
console.log(
|
|
28
|
+
console.log(
|
|
29
|
+
'\u274C StackMemory not initialized. Run "stackmemory init" first.'
|
|
30
|
+
);
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
33
|
const displayDashboard = async () => {
|
|
32
34
|
console.clear();
|
|
33
|
-
console.log(
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
console.log(
|
|
36
|
+
chalk.cyan.bold(
|
|
37
|
+
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
console.log(
|
|
41
|
+
chalk.cyan.bold(
|
|
42
|
+
" \u{1F680} StackMemory Monitoring Dashboard "
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
console.log(
|
|
46
|
+
chalk.cyan.bold(
|
|
47
|
+
"\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"
|
|
48
|
+
)
|
|
49
|
+
);
|
|
36
50
|
console.log();
|
|
37
51
|
const sessionManager = new SessionManager({ enableMonitoring: false });
|
|
38
52
|
await sessionManager.initialize();
|
|
@@ -52,8 +66,12 @@ const dashboardCommand = {
|
|
|
52
66
|
style: { head: [], border: [] }
|
|
53
67
|
});
|
|
54
68
|
sessions.forEach((session) => {
|
|
55
|
-
const duration = Math.round(
|
|
56
|
-
|
|
69
|
+
const duration = Math.round(
|
|
70
|
+
(Date.now() - session.startedAt) / 1e3 / 60
|
|
71
|
+
);
|
|
72
|
+
const lastActive = Math.round(
|
|
73
|
+
(Date.now() - session.lastActiveAt) / 1e3 / 60
|
|
74
|
+
);
|
|
57
75
|
const status = session.state === "active" ? chalk.green("\u25CF Active") : session.state === "completed" ? chalk.gray("\u25CF Completed") : chalk.yellow("\u25CF Idle");
|
|
58
76
|
sessionsTable.push([
|
|
59
77
|
session.sessionId.substring(0, 8),
|
|
@@ -66,13 +84,15 @@ const dashboardCommand = {
|
|
|
66
84
|
console.log(chalk.yellow.bold("\u{1F4CA} Active Sessions"));
|
|
67
85
|
console.log(sessionsTable.toString());
|
|
68
86
|
console.log();
|
|
69
|
-
const frameStats = db.prepare(
|
|
87
|
+
const frameStats = db.prepare(
|
|
88
|
+
`
|
|
70
89
|
SELECT
|
|
71
90
|
COUNT(*) as total,
|
|
72
91
|
SUM(CASE WHEN state = 'active' THEN 1 ELSE 0 END) as active,
|
|
73
92
|
COUNT(DISTINCT run_id) as sessions
|
|
74
93
|
FROM frames
|
|
75
|
-
`
|
|
94
|
+
`
|
|
95
|
+
).get();
|
|
76
96
|
const statsTable = new Table({
|
|
77
97
|
head: [chalk.white("Metric"), chalk.white("Value")],
|
|
78
98
|
style: { head: [], border: [] }
|
|
@@ -85,7 +105,8 @@ const dashboardCommand = {
|
|
|
85
105
|
console.log(chalk.yellow.bold("\u{1F4C8} Frame Statistics"));
|
|
86
106
|
console.log(statsTable.toString());
|
|
87
107
|
console.log();
|
|
88
|
-
const recentActivity = db.prepare(
|
|
108
|
+
const recentActivity = db.prepare(
|
|
109
|
+
`
|
|
89
110
|
SELECT
|
|
90
111
|
name,
|
|
91
112
|
type,
|
|
@@ -94,7 +115,8 @@ const dashboardCommand = {
|
|
|
94
115
|
FROM frames
|
|
95
116
|
ORDER BY created_at DESC
|
|
96
117
|
LIMIT 5
|
|
97
|
-
`
|
|
118
|
+
`
|
|
119
|
+
).all();
|
|
98
120
|
if (recentActivity.length > 0) {
|
|
99
121
|
const activityTable = new Table({
|
|
100
122
|
head: [
|
|
@@ -125,7 +147,11 @@ const dashboardCommand = {
|
|
|
125
147
|
console.log();
|
|
126
148
|
db.close();
|
|
127
149
|
if (argv.watch) {
|
|
128
|
-
console.log(
|
|
150
|
+
console.log(
|
|
151
|
+
chalk.gray(
|
|
152
|
+
`Auto-refreshing every ${argv.interval} seconds. Press Ctrl+C to exit.`
|
|
153
|
+
)
|
|
154
|
+
);
|
|
129
155
|
} else {
|
|
130
156
|
console.log(chalk.gray("Run with --watch to auto-refresh"));
|
|
131
157
|
}
|
|
@@ -159,14 +185,16 @@ function createProgressBar(value, max) {
|
|
|
159
185
|
return color("\u2588".repeat(filled)) + chalk.gray("\u2591".repeat(empty));
|
|
160
186
|
}
|
|
161
187
|
async function estimateContextUsage(db) {
|
|
162
|
-
const result = db.prepare(
|
|
188
|
+
const result = db.prepare(
|
|
189
|
+
`
|
|
163
190
|
SELECT
|
|
164
191
|
COUNT(*) as frame_count,
|
|
165
192
|
SUM(LENGTH(inputs)) as input_size,
|
|
166
193
|
SUM(LENGTH(outputs)) as output_size
|
|
167
194
|
FROM frames
|
|
168
195
|
WHERE state = 'active'
|
|
169
|
-
`
|
|
196
|
+
`
|
|
197
|
+
).get();
|
|
170
198
|
const totalBytes = (result.input_size || 0) + (result.output_size || 0);
|
|
171
199
|
const estimatedTokens = totalBytes / 4;
|
|
172
200
|
const maxTokens = 128e3;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/commands/dashboard.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n/**\n * Dashboard Command - Display monitoring dashboard in terminal\n */\n\nimport chalk from 'chalk';\nimport Table from 'cli-table3';\nimport { SessionManager } from '../../core/session/session-manager.js';\nimport { FrameManager } from '../../core/context/frame-manager.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\n\nexport const dashboardCommand = {\n command: 'dashboard',\n describe: 'Display monitoring dashboard in terminal',\n builder: (yargs: any) => {\n return yargs\n .option('watch', {\n alias: 'w',\n type: 'boolean',\n description: 'Auto-refresh dashboard',\n default: false
|
|
5
|
-
"mappings": ";AAKA,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,SAAS,sBAAsB;AAE/B,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAEpB,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UAAe;AACvB,WAAO,MACJ,OAAO,SAAS;AAAA,MACf,OAAO;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC,EACA,OAAO,YAAY;AAAA,MAClB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,EACL;AAAA,EACA,SAAS,OAAO,SAAc;AAC5B,UAAM,cAAc,QAAQ,IAAI;AAChC,UAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAE7D,QAAI,CAAC,WAAW,MAAM,GAAG;AACvB,cAAQ,
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n/**\n * Dashboard Command - Display monitoring dashboard in terminal\n */\n\nimport chalk from 'chalk';\nimport Table from 'cli-table3';\nimport { SessionManager } from '../../core/session/session-manager.js';\nimport { FrameManager } from '../../core/context/frame-manager.js';\nimport Database from 'better-sqlite3';\nimport { join } from 'path';\nimport { existsSync } from 'fs';\n\nexport const dashboardCommand = {\n command: 'dashboard',\n describe: 'Display monitoring dashboard in terminal',\n builder: (yargs: any) => {\n return yargs\n .option('watch', {\n alias: 'w',\n type: 'boolean',\n description: 'Auto-refresh dashboard',\n default: false,\n })\n .option('interval', {\n alias: 'i',\n type: 'number',\n description: 'Refresh interval in seconds',\n default: 5,\n });\n },\n handler: async (argv: any) => {\n const projectRoot = process.cwd();\n const dbPath = join(projectRoot, '.stackmemory', 'context.db');\n\n if (!existsSync(dbPath)) {\n console.log(\n '\u274C StackMemory not initialized. Run \"stackmemory init\" first.'\n );\n return;\n }\n\n const displayDashboard = async () => {\n console.clear();\n\n // Header\n console.log(\n chalk.cyan.bold(\n '\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550'\n )\n );\n console.log(\n chalk.cyan.bold(\n ' \uD83D\uDE80 StackMemory Monitoring Dashboard '\n )\n );\n console.log(\n chalk.cyan.bold(\n '\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550'\n )\n );\n console.log();\n\n const sessionManager = new SessionManager({ enableMonitoring: false });\n await sessionManager.initialize();\n\n const db = new Database(dbPath);\n\n // Get sessions\n const sessions = await sessionManager.listSessions({\n state: 'active',\n limit: 5,\n });\n\n // Sessions Table\n const sessionsTable = new Table({\n head: [\n chalk.white('Session ID'),\n chalk.white('Status'),\n chalk.white('Branch'),\n chalk.white('Duration'),\n chalk.white('Last Active'),\n ],\n style: { head: [], border: [] },\n });\n\n sessions.forEach((session) => {\n const duration = Math.round(\n (Date.now() - session.startedAt) / 1000 / 60\n );\n const lastActive = Math.round(\n (Date.now() - session.lastActiveAt) / 1000 / 60\n );\n const status =\n session.state === 'active'\n ? chalk.green('\u25CF Active')\n : session.state === 'completed'\n ? chalk.gray('\u25CF Completed')\n : chalk.yellow('\u25CF Idle');\n\n sessionsTable.push([\n session.sessionId.substring(0, 8),\n status,\n session.branch || 'main',\n `${duration}m`,\n `${lastActive}m ago`,\n ]);\n });\n\n console.log(chalk.yellow.bold('\uD83D\uDCCA Active Sessions'));\n console.log(sessionsTable.toString());\n console.log();\n\n // Frame Statistics\n const frameStats = db\n .prepare(\n `\n SELECT \n COUNT(*) as total,\n SUM(CASE WHEN state = 'active' THEN 1 ELSE 0 END) as active,\n COUNT(DISTINCT run_id) as sessions\n FROM frames\n `\n )\n .get() as any;\n\n const statsTable = new Table({\n head: [chalk.white('Metric'), chalk.white('Value')],\n style: { head: [], border: [] },\n });\n\n statsTable.push(\n ['Total Frames', frameStats.total || 0],\n ['Active Frames', chalk.green(frameStats.active || 0)],\n ['Total Sessions', frameStats.sessions || 0]\n );\n\n console.log(chalk.yellow.bold('\uD83D\uDCC8 Frame Statistics'));\n console.log(statsTable.toString());\n console.log();\n\n // Recent Activity\n const recentActivity = db\n .prepare(\n `\n SELECT \n name,\n type,\n state,\n datetime(created_at, 'unixepoch') as created\n FROM frames\n ORDER BY created_at DESC\n LIMIT 5\n `\n )\n .all() as any[];\n\n if (recentActivity.length > 0) {\n const activityTable = new Table({\n head: [\n chalk.white('Frame'),\n chalk.white('Type'),\n chalk.white('Status'),\n chalk.white('Created'),\n ],\n style: { head: [], border: [] },\n });\n\n recentActivity.forEach((frame) => {\n const status =\n frame.state === 'active'\n ? chalk.green('Active')\n : chalk.gray('Closed');\n\n activityTable.push([\n frame.name.substring(0, 30),\n frame.type,\n status,\n frame.created,\n ]);\n });\n\n console.log(chalk.yellow.bold('\uD83D\uDD50 Recent Activity'));\n console.log(activityTable.toString());\n console.log();\n }\n\n // Memory Usage\n const contextUsage = await estimateContextUsage(db);\n const usageBar = createProgressBar(contextUsage, 100);\n\n console.log(chalk.yellow.bold('\uD83D\uDCBE Context Usage'));\n console.log(`${usageBar} ${contextUsage}%`);\n console.log();\n\n db.close();\n\n // Footer\n if (argv.watch) {\n console.log(\n chalk.gray(\n `Auto-refreshing every ${argv.interval} seconds. Press Ctrl+C to exit.`\n )\n );\n } else {\n console.log(chalk.gray('Run with --watch to auto-refresh'));\n }\n };\n\n try {\n await displayDashboard();\n\n if (argv.watch) {\n const interval = setInterval(async () => {\n await displayDashboard();\n }, argv.interval * 1000);\n\n process.on('SIGINT', () => {\n clearInterval(interval);\n console.clear();\n console.log(chalk.green('\u2705 Dashboard closed'));\n process.exit(0);\n });\n }\n } catch (error: unknown) {\n console.error(chalk.red('\u274C Dashboard error:'), (error as Error).message);\n process.exit(1);\n }\n },\n};\n\nfunction createProgressBar(value: number, max: number): string {\n const percentage = Math.min(100, Math.round((value / max) * 100));\n const filled = Math.round(percentage / 5);\n const empty = 20 - filled;\n\n let color = chalk.green;\n if (percentage > 80) color = chalk.red;\n else if (percentage > 60) color = chalk.yellow;\n\n return color('\u2588'.repeat(filled)) + chalk.gray('\u2591'.repeat(empty));\n}\n\nasync function estimateContextUsage(db: Database): Promise<number> {\n const result = db\n .prepare(\n `\n SELECT \n COUNT(*) as frame_count,\n SUM(LENGTH(inputs)) as input_size,\n SUM(LENGTH(outputs)) as output_size\n FROM frames\n WHERE state = 'active'\n `\n )\n .get() as any;\n\n // Rough estimate: assume average token is 4 bytes\n const totalBytes = (result.input_size || 0) + (result.output_size || 0);\n const estimatedTokens = totalBytes / 4;\n const maxTokens = 128000; // Claude's context window\n\n return Math.round((estimatedTokens / maxTokens) * 100);\n}\n"],
|
|
5
|
+
"mappings": ";AAKA,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,SAAS,sBAAsB;AAE/B,OAAO,cAAc;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAEpB,MAAM,mBAAmB;AAAA,EAC9B,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS,CAAC,UAAe;AACvB,WAAO,MACJ,OAAO,SAAS;AAAA,MACf,OAAO;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC,EACA,OAAO,YAAY;AAAA,MAClB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,IACX,CAAC;AAAA,EACL;AAAA,EACA,SAAS,OAAO,SAAc;AAC5B,UAAM,cAAc,QAAQ,IAAI;AAChC,UAAM,SAAS,KAAK,aAAa,gBAAgB,YAAY;AAE7D,QAAI,CAAC,WAAW,MAAM,GAAG;AACvB,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,mBAAmB,YAAY;AACnC,cAAQ,MAAM;AAGd,cAAQ;AAAA,QACN,MAAM,KAAK;AAAA,UACT;AAAA,QACF;AAAA,MACF;AACA,cAAQ;AAAA,QACN,MAAM,KAAK;AAAA,UACT;AAAA,QACF;AAAA,MACF;AACA,cAAQ;AAAA,QACN,MAAM,KAAK;AAAA,UACT;AAAA,QACF;AAAA,MACF;AACA,cAAQ,IAAI;AAEZ,YAAM,iBAAiB,IAAI,eAAe,EAAE,kBAAkB,MAAM,CAAC;AACrE,YAAM,eAAe,WAAW;AAEhC,YAAM,KAAK,IAAI,SAAS,MAAM;AAG9B,YAAM,WAAW,MAAM,eAAe,aAA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