aspectcode 0.4.0 → 1.0.0
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/README.md +13 -0
- package/dist/agentsMdRenderer.d.ts +16 -0
- package/dist/agentsMdRenderer.d.ts.map +1 -0
- package/dist/agentsMdRenderer.js +137 -0
- package/dist/agentsMdRenderer.js.map +1 -0
- package/dist/auth.d.ts +31 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +385 -0
- package/dist/auth.js.map +1 -0
- package/dist/autoResolve.d.ts +41 -0
- package/dist/autoResolve.d.ts.map +1 -0
- package/dist/autoResolve.js +196 -0
- package/dist/autoResolve.js.map +1 -0
- package/dist/changeEvaluator.d.ts +56 -0
- package/dist/changeEvaluator.d.ts.map +1 -0
- package/dist/changeEvaluator.js +674 -0
- package/dist/changeEvaluator.js.map +1 -0
- package/dist/cli.d.ts +12 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +37 -17
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +50 -2
- package/dist/config.js.map +1 -1
- package/dist/dreamCycle.d.ts +57 -0
- package/dist/dreamCycle.d.ts.map +1 -0
- package/dist/dreamCycle.js +334 -0
- package/dist/dreamCycle.js.map +1 -0
- package/dist/kbBuilder.d.ts +1 -2
- package/dist/kbBuilder.d.ts.map +1 -1
- package/dist/kbBuilder.js +1 -2
- package/dist/kbBuilder.js.map +1 -1
- package/dist/main.d.ts +2 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -8
- package/dist/main.js.map +1 -1
- package/dist/optimize.d.ts +13 -6
- package/dist/optimize.d.ts.map +1 -1
- package/dist/optimize.js +433 -142
- package/dist/optimize.js.map +1 -1
- package/dist/pipeline.d.ts +21 -18
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +1139 -162
- package/dist/pipeline.js.map +1 -1
- package/dist/preferences.d.ts +80 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +238 -0
- package/dist/preferences.js.map +1 -0
- package/dist/runtimeState.d.ts +30 -0
- package/dist/runtimeState.d.ts.map +1 -0
- package/dist/runtimeState.js +39 -0
- package/dist/runtimeState.js.map +1 -0
- package/dist/scopedRules.d.ts +84 -0
- package/dist/scopedRules.d.ts.map +1 -0
- package/dist/scopedRules.js +449 -0
- package/dist/scopedRules.js.map +1 -0
- package/dist/ui/Dashboard.d.ts +4 -16
- package/dist/ui/Dashboard.d.ts.map +1 -1
- package/dist/ui/Dashboard.js +339 -141
- package/dist/ui/Dashboard.js.map +1 -1
- package/dist/ui/MemoryMap.d.ts +16 -0
- package/dist/ui/MemoryMap.d.ts.map +1 -0
- package/dist/ui/MemoryMap.js +266 -0
- package/dist/ui/MemoryMap.js.map +1 -0
- package/dist/ui/SettingsPanel.d.ts +18 -0
- package/dist/ui/SettingsPanel.d.ts.map +1 -0
- package/dist/ui/SettingsPanel.js +241 -0
- package/dist/ui/SettingsPanel.js.map +1 -0
- package/dist/ui/prompts.d.ts +7 -0
- package/dist/ui/prompts.d.ts.map +1 -1
- package/dist/ui/prompts.js +63 -0
- package/dist/ui/prompts.js.map +1 -1
- package/dist/ui/store.d.ts +154 -18
- package/dist/ui/store.d.ts.map +1 -1
- package/dist/ui/store.js +154 -24
- package/dist/ui/store.js.map +1 -1
- package/dist/ui/theme.d.ts +1 -8
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +2 -20
- package/dist/ui/theme.js.map +1 -1
- package/dist/updateChecker.d.ts +13 -0
- package/dist/updateChecker.d.ts.map +1 -0
- package/dist/updateChecker.js +66 -0
- package/dist/updateChecker.js.map +1 -0
- package/dist/usageTracker.d.ts +12 -0
- package/dist/usageTracker.d.ts.map +1 -0
- package/dist/usageTracker.js +89 -0
- package/dist/usageTracker.js.map +1 -0
- package/dist/writer.d.ts +1 -7
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js +1 -11
- package/dist/writer.js.map +1 -1
- package/node_modules/@aspectcode/core/dist/analysis/repo.d.ts.map +1 -1
- package/node_modules/@aspectcode/core/dist/analysis/repo.js +13 -2
- package/node_modules/@aspectcode/core/dist/analysis/repo.js.map +1 -1
- package/node_modules/@aspectcode/core/dist/index.d.ts +1 -3
- package/node_modules/@aspectcode/core/dist/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/core/dist/index.js +1 -3
- package/node_modules/@aspectcode/core/dist/index.js.map +1 -1
- package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.d.ts +14 -0
- package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.d.ts.map +1 -0
- package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.js +191 -0
- package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.js.map +1 -0
- package/node_modules/@aspectcode/core/dist/parsers/index.d.ts +1 -0
- package/node_modules/@aspectcode/core/dist/parsers/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/core/dist/parsers/index.js +6 -1
- package/node_modules/@aspectcode/core/dist/parsers/index.js.map +1 -1
- package/node_modules/@aspectcode/core/dist/parsers/languages.d.ts +20 -0
- package/node_modules/@aspectcode/core/dist/parsers/languages.d.ts.map +1 -1
- package/node_modules/@aspectcode/core/dist/parsers/languages.js +25 -0
- package/node_modules/@aspectcode/core/dist/parsers/languages.js.map +1 -1
- package/node_modules/@aspectcode/core/dist/parsers/tsJsExtractors.d.ts.map +1 -1
- package/node_modules/@aspectcode/core/dist/parsers/tsJsExtractors.js +4 -1
- package/node_modules/@aspectcode/core/dist/parsers/tsJsExtractors.js.map +1 -1
- package/node_modules/@aspectcode/core/package.json +2 -2
- package/node_modules/@aspectcode/core/parsers/cpp.wasm +0 -0
- package/node_modules/@aspectcode/core/parsers/go.wasm +0 -0
- package/node_modules/@aspectcode/core/parsers/php.wasm +0 -0
- package/node_modules/@aspectcode/core/parsers/ruby.wasm +0 -0
- package/node_modules/@aspectcode/core/parsers/rust.wasm +0 -0
- package/node_modules/@aspectcode/emitters/dist/index.d.ts +1 -17
- package/node_modules/@aspectcode/emitters/dist/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/index.js +2 -89
- package/node_modules/@aspectcode/emitters/dist/index.js.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/index.d.ts +0 -2
- package/node_modules/@aspectcode/emitters/dist/instructions/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/index.js +1 -7
- package/node_modules/@aspectcode/emitters/dist/instructions/index.js.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/kb/analyzers.d.ts +0 -18
- package/node_modules/@aspectcode/emitters/dist/kb/analyzers.d.ts.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/kb/analyzers.js +0 -57
- package/node_modules/@aspectcode/emitters/dist/kb/analyzers.js.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/kb/conventions.d.ts +0 -18
- package/node_modules/@aspectcode/emitters/dist/kb/conventions.d.ts.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/kb/conventions.js +0 -130
- package/node_modules/@aspectcode/emitters/dist/kb/conventions.js.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/kb/index.d.ts +2 -4
- package/node_modules/@aspectcode/emitters/dist/kb/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/emitters/dist/kb/index.js +1 -11
- package/node_modules/@aspectcode/emitters/dist/kb/index.js.map +1 -1
- package/node_modules/@aspectcode/emitters/package.json +3 -3
- package/node_modules/@aspectcode/evaluator/dist/apply.d.ts +55 -0
- package/node_modules/@aspectcode/evaluator/dist/apply.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/apply.js +368 -0
- package/node_modules/@aspectcode/evaluator/dist/apply.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.d.ts +16 -25
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.d.ts.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.js +115 -138
- package/node_modules/@aspectcode/evaluator/dist/diagnosis.js.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/index.d.ts +8 -43
- package/node_modules/@aspectcode/evaluator/dist/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/index.js +15 -61
- package/node_modules/@aspectcode/evaluator/dist/index.js.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/judge.d.ts +32 -0
- package/node_modules/@aspectcode/evaluator/dist/judge.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/judge.js +165 -0
- package/node_modules/@aspectcode/evaluator/dist/judge.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/llmUtil.d.ts +15 -0
- package/node_modules/@aspectcode/evaluator/dist/llmUtil.d.ts.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/llmUtil.js +41 -0
- package/node_modules/@aspectcode/evaluator/dist/llmUtil.js.map +1 -0
- package/node_modules/@aspectcode/evaluator/dist/probes.d.ts +20 -29
- package/node_modules/@aspectcode/evaluator/dist/probes.d.ts.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/probes.js +188 -204
- package/node_modules/@aspectcode/evaluator/dist/probes.js.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/runner.d.ts +7 -32
- package/node_modules/@aspectcode/evaluator/dist/runner.d.ts.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/runner.js +21 -146
- package/node_modules/@aspectcode/evaluator/dist/runner.js.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/types.d.ts +141 -99
- package/node_modules/@aspectcode/evaluator/dist/types.d.ts.map +1 -1
- package/node_modules/@aspectcode/evaluator/dist/types.js +10 -2
- package/node_modules/@aspectcode/evaluator/dist/types.js.map +1 -1
- package/node_modules/@aspectcode/evaluator/package.json +4 -4
- package/node_modules/@aspectcode/optimizer/dist/index.d.ts +3 -10
- package/node_modules/@aspectcode/optimizer/dist/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/index.js +1 -19
- package/node_modules/@aspectcode/optimizer/dist/index.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.js +40 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.d.ts +9 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.d.ts.map +1 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.js +83 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.js.map +1 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/index.d.ts +4 -3
- package/node_modules/@aspectcode/optimizer/dist/providers/index.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/index.js +24 -10
- package/node_modules/@aspectcode/optimizer/dist/providers/index.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/openai.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/openai.js +22 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/openai.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/retry.d.ts +14 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/retry.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/providers/retry.js +1 -0
- package/node_modules/@aspectcode/optimizer/dist/providers/retry.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/types.d.ts +14 -0
- package/node_modules/@aspectcode/optimizer/dist/types.d.ts.map +1 -1
- package/node_modules/@aspectcode/optimizer/dist/types.js.map +1 -1
- package/node_modules/@aspectcode/optimizer/package.json +2 -2
- package/package.json +6 -7
- package/dist/complaintProcessor.d.ts +0 -16
- package/dist/complaintProcessor.d.ts.map +0 -1
- package/dist/complaintProcessor.js +0 -134
- package/dist/complaintProcessor.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/emitter.d.ts +0 -72
- package/node_modules/@aspectcode/emitters/dist/emitter.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/emitter.js +0 -10
- package/node_modules/@aspectcode/emitters/dist/emitter.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/content.d.ts +0 -15
- package/node_modules/@aspectcode/emitters/dist/instructions/content.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/content.js +0 -289
- package/node_modules/@aspectcode/emitters/dist/instructions/content.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/detection.d.ts +0 -13
- package/node_modules/@aspectcode/emitters/dist/instructions/detection.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/detection.js +0 -55
- package/node_modules/@aspectcode/emitters/dist/instructions/detection.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.d.ts +0 -9
- package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.js +0 -30
- package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.d.ts +0 -21
- package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.js +0 -125
- package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/manifest.d.ts +0 -37
- package/node_modules/@aspectcode/emitters/dist/manifest.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/manifest.js +0 -50
- package/node_modules/@aspectcode/emitters/dist/manifest.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/report.d.ts +0 -22
- package/node_modules/@aspectcode/emitters/dist/report.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/report.js +0 -3
- package/node_modules/@aspectcode/emitters/dist/report.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/stableJson.d.ts +0 -14
- package/node_modules/@aspectcode/emitters/dist/stableJson.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/stableJson.js +0 -40
- package/node_modules/@aspectcode/emitters/dist/stableJson.js.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/transaction.d.ts +0 -29
- package/node_modules/@aspectcode/emitters/dist/transaction.d.ts.map +0 -1
- package/node_modules/@aspectcode/emitters/dist/transaction.js +0 -104
- package/node_modules/@aspectcode/emitters/dist/transaction.js.map +0 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dream cycle — consolidates developer corrections into refined AGENTS.md rules.
|
|
4
|
+
*
|
|
5
|
+
* Tracks y/n corrections during watch mode. After enough accumulate,
|
|
6
|
+
* a single LLM call integrates them into AGENTS.md: strengthening
|
|
7
|
+
* confirmed problems and softening over-flagged warnings.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.LEARNED_END = exports.LEARNED_START = void 0;
|
|
44
|
+
exports.addCorrection = addCorrection;
|
|
45
|
+
exports.getCorrections = getCorrections;
|
|
46
|
+
exports.getUnprocessedCount = getUnprocessedCount;
|
|
47
|
+
exports.shouldDream = shouldDream;
|
|
48
|
+
exports.markProcessed = markProcessed;
|
|
49
|
+
exports.resetCorrections = resetCorrections;
|
|
50
|
+
exports.loadDreamState = loadDreamState;
|
|
51
|
+
exports.saveDreamState = saveDreamState;
|
|
52
|
+
exports.deriveLearnedRule = deriveLearnedRule;
|
|
53
|
+
exports.appendLearnedRule = appendLearnedRule;
|
|
54
|
+
exports.getLearnedRules = getLearnedRules;
|
|
55
|
+
exports.stripLearnedBlock = stripLearnedBlock;
|
|
56
|
+
exports.parseDreamResponse = parseDreamResponse;
|
|
57
|
+
exports.runDreamCycle = runDreamCycle;
|
|
58
|
+
const fs = __importStar(require("fs"));
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const optimizer_1 = require("@aspectcode/optimizer");
|
|
61
|
+
// ── Constants ────────────────────────────────────────────────
|
|
62
|
+
const DREAM_THRESHOLD = 10;
|
|
63
|
+
const DIR_NAME = '.aspectcode';
|
|
64
|
+
const STATE_FILE = 'dream-state.json';
|
|
65
|
+
// ── Learned rule markers ─────────────────────────────────────
|
|
66
|
+
exports.LEARNED_START = '<!-- aspectcode:learned -->';
|
|
67
|
+
exports.LEARNED_END = '<!-- /aspectcode:learned -->';
|
|
68
|
+
// ── In-memory correction tracker ─────────────────────────────
|
|
69
|
+
const corrections = [];
|
|
70
|
+
function addCorrection(action, assessment) {
|
|
71
|
+
corrections.push({ timestamp: Date.now(), action, assessment });
|
|
72
|
+
}
|
|
73
|
+
function getCorrections() {
|
|
74
|
+
return [...corrections];
|
|
75
|
+
}
|
|
76
|
+
function getUnprocessedCount() {
|
|
77
|
+
return corrections.length;
|
|
78
|
+
}
|
|
79
|
+
function shouldDream() {
|
|
80
|
+
return corrections.length >= DREAM_THRESHOLD;
|
|
81
|
+
}
|
|
82
|
+
function markProcessed() {
|
|
83
|
+
corrections.length = 0;
|
|
84
|
+
}
|
|
85
|
+
/** Reset tracker (for testing). */
|
|
86
|
+
function resetCorrections() {
|
|
87
|
+
corrections.length = 0;
|
|
88
|
+
}
|
|
89
|
+
// ── Persistence ──────────────────────────────────────────────
|
|
90
|
+
function loadDreamState(root) {
|
|
91
|
+
const p = path.join(root, DIR_NAME, STATE_FILE);
|
|
92
|
+
try {
|
|
93
|
+
if (fs.existsSync(p)) {
|
|
94
|
+
return JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch { /* ignore */ }
|
|
98
|
+
return { lastDreamAt: '' };
|
|
99
|
+
}
|
|
100
|
+
function saveDreamState(root, state) {
|
|
101
|
+
const dir = path.join(root, DIR_NAME);
|
|
102
|
+
if (!fs.existsSync(dir))
|
|
103
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
104
|
+
fs.writeFileSync(path.join(dir, STATE_FILE), JSON.stringify(state, null, 2) + '\n');
|
|
105
|
+
}
|
|
106
|
+
// ── Learned rule derivation ──────────────────────────────────
|
|
107
|
+
function deriveLearnedRule(assessment) {
|
|
108
|
+
const { file, rule, message, details, dependencyContext } = assessment;
|
|
109
|
+
switch (rule) {
|
|
110
|
+
case 'co-change': {
|
|
111
|
+
// Extract dependent info from dependencyContext
|
|
112
|
+
const missingMatch = dependencyContext?.match(/missing: \[([^\]]+)\]/);
|
|
113
|
+
const dependents = missingMatch ? missingMatch[1] : details ?? '';
|
|
114
|
+
return `When modifying ${file}, verify dependents: ${dependents}`;
|
|
115
|
+
}
|
|
116
|
+
case 'export-contract': {
|
|
117
|
+
const consumers = details ?? '';
|
|
118
|
+
return `When removing exports from ${file}, update consumers: ${consumers}`;
|
|
119
|
+
}
|
|
120
|
+
case 'circular-dependency': {
|
|
121
|
+
const cycle = details ?? message;
|
|
122
|
+
return `Avoid circular imports involving ${file} — ${cycle}`;
|
|
123
|
+
}
|
|
124
|
+
case 'test-coverage-gap': {
|
|
125
|
+
const testFile = details?.match(/^(\S+)/)?.[1] ?? '';
|
|
126
|
+
return `When changing ${file}, update ${testFile}`;
|
|
127
|
+
}
|
|
128
|
+
default:
|
|
129
|
+
return `${rule}: ${message}`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// ── Learned rule marker helpers ──────────────────────────────
|
|
133
|
+
function appendLearnedRule(agentsMd, rule) {
|
|
134
|
+
const bullet = `- ${rule}`;
|
|
135
|
+
if (agentsMd.includes(exports.LEARNED_START) && agentsMd.includes(exports.LEARNED_END)) {
|
|
136
|
+
// Insert before end marker
|
|
137
|
+
const endIdx = agentsMd.indexOf(exports.LEARNED_END);
|
|
138
|
+
return agentsMd.slice(0, endIdx) + bullet + '\n' + agentsMd.slice(endIdx);
|
|
139
|
+
}
|
|
140
|
+
// Append new block at the end
|
|
141
|
+
const separator = agentsMd.endsWith('\n') ? '\n' : '\n\n';
|
|
142
|
+
return agentsMd + separator + exports.LEARNED_START + '\n' + bullet + '\n' + exports.LEARNED_END + '\n';
|
|
143
|
+
}
|
|
144
|
+
function getLearnedRules(agentsMd) {
|
|
145
|
+
if (!agentsMd.includes(exports.LEARNED_START) || !agentsMd.includes(exports.LEARNED_END))
|
|
146
|
+
return [];
|
|
147
|
+
const startIdx = agentsMd.indexOf(exports.LEARNED_START) + exports.LEARNED_START.length;
|
|
148
|
+
const endIdx = agentsMd.indexOf(exports.LEARNED_END);
|
|
149
|
+
const block = agentsMd.slice(startIdx, endIdx);
|
|
150
|
+
return block
|
|
151
|
+
.split('\n')
|
|
152
|
+
.map((l) => l.trim())
|
|
153
|
+
.filter((l) => l.startsWith('- '))
|
|
154
|
+
.map((l) => l.slice(2));
|
|
155
|
+
}
|
|
156
|
+
function stripLearnedBlock(agentsMd) {
|
|
157
|
+
if (!agentsMd.includes(exports.LEARNED_START) || !agentsMd.includes(exports.LEARNED_END))
|
|
158
|
+
return agentsMd;
|
|
159
|
+
const startIdx = agentsMd.indexOf(exports.LEARNED_START);
|
|
160
|
+
const endIdx = agentsMd.indexOf(exports.LEARNED_END) + exports.LEARNED_END.length;
|
|
161
|
+
// Also strip surrounding whitespace/newlines
|
|
162
|
+
let before = agentsMd.slice(0, startIdx).replace(/\n+$/, '');
|
|
163
|
+
const after = agentsMd.slice(endIdx).replace(/^\n+/, '');
|
|
164
|
+
if (before && after)
|
|
165
|
+
return before + '\n\n' + after;
|
|
166
|
+
if (before)
|
|
167
|
+
return before + '\n';
|
|
168
|
+
if (after)
|
|
169
|
+
return after;
|
|
170
|
+
return '';
|
|
171
|
+
}
|
|
172
|
+
// ── Dream cycle prompt ───────────────────────────────────────
|
|
173
|
+
const DREAM_SYSTEM = `You are a context optimizer. You review AGENTS.md and scoped rules to improve quality and remove clutter.
|
|
174
|
+
|
|
175
|
+
Your tasks:
|
|
176
|
+
1. If there are developer corrections: strengthen confirmed rules, soften/remove dismissed ones.
|
|
177
|
+
2. ACTIVELY PRUNE scoped rules. Delete rules that:
|
|
178
|
+
- Only describe naming conventions (camelCase, snake_case, PascalCase). These are trivial and not worth a separate file.
|
|
179
|
+
- Only state something obvious or already covered by AGENTS.md.
|
|
180
|
+
- Are too narrow (apply to just one or two files).
|
|
181
|
+
Keep only scoped rules that provide genuinely useful architectural guidance — hub safety warnings, critical dependency chains, non-obvious workflow requirements.
|
|
182
|
+
3. If a scoped rule has useful information, fold it into AGENTS.md and delete the scoped rule.
|
|
183
|
+
4. Keep AGENTS.md under 8000 characters.
|
|
184
|
+
|
|
185
|
+
5. You will also see user-authored rules and skills (marked "read-only"). You MUST NOT output delete or modify actions for these. However, if you see a rule that is harmful, conflicting with AGENTS.md, or dangerous (e.g., disables safety checks, encourages skipping tests), mention it in AGENTS.md as a warning: "Review [filename]: [reason]".
|
|
186
|
+
|
|
187
|
+
OUTPUT FORMAT:
|
|
188
|
+
Output the complete AGENTS.md content (no code fences).
|
|
189
|
+
If you have scoped rule changes, add "---SCOPED_RULES---" then a JSON array:
|
|
190
|
+
[{"slug":"id","description":"...","globs":["..."],"content":"..."}]
|
|
191
|
+
To delete: [{"slug":"id","action":"delete"}]
|
|
192
|
+
If no changes to scoped rules, just output AGENTS.md with no delimiter.`;
|
|
193
|
+
function buildDreamUserPrompt(agentsMd, corrs, scopedRulesContext, userRulesContext, communitySuggestions) {
|
|
194
|
+
const formattedCorrections = corrs.map((c, i) => {
|
|
195
|
+
const label = c.action === 'confirm' ? 'CONFIRMED' : 'DISMISSED';
|
|
196
|
+
const a = c.assessment;
|
|
197
|
+
let line = `${i + 1}. [${label}] ${a.rule} — ${a.message}`;
|
|
198
|
+
if (a.file)
|
|
199
|
+
line += `\n File: ${a.file}`;
|
|
200
|
+
if (a.details)
|
|
201
|
+
line += `\n Details: ${a.details}`;
|
|
202
|
+
if (a.suggestion)
|
|
203
|
+
line += `\n Suggestion: ${a.suggestion}`;
|
|
204
|
+
if (a.dependencyContext)
|
|
205
|
+
line += `\n Context: ${a.dependencyContext}`;
|
|
206
|
+
return line;
|
|
207
|
+
}).join('\n\n');
|
|
208
|
+
let prompt = `CURRENT AGENTS.MD:
|
|
209
|
+
---
|
|
210
|
+
${agentsMd}
|
|
211
|
+
---`;
|
|
212
|
+
if (scopedRulesContext) {
|
|
213
|
+
prompt += `
|
|
214
|
+
|
|
215
|
+
CURRENT SCOPED RULES:
|
|
216
|
+
---
|
|
217
|
+
${scopedRulesContext}
|
|
218
|
+
---`;
|
|
219
|
+
}
|
|
220
|
+
if (userRulesContext) {
|
|
221
|
+
prompt += `
|
|
222
|
+
|
|
223
|
+
USER-AUTHORED RULES AND SKILLS (read-only — do NOT delete or modify these):
|
|
224
|
+
---
|
|
225
|
+
${userRulesContext}
|
|
226
|
+
---`;
|
|
227
|
+
}
|
|
228
|
+
if (corrs.length > 0) {
|
|
229
|
+
prompt += `
|
|
230
|
+
|
|
231
|
+
CORRECTIONS (from watch mode):
|
|
232
|
+
${formattedCorrections}`;
|
|
233
|
+
}
|
|
234
|
+
if (communitySuggestions) {
|
|
235
|
+
prompt += `
|
|
236
|
+
|
|
237
|
+
COMMUNITY INSIGHTS (from similar ${corrs.length > 0 ? '' : 'open-source '}projects — integrate only what's relevant to THIS project):
|
|
238
|
+
${communitySuggestions}`;
|
|
239
|
+
}
|
|
240
|
+
prompt += `
|
|
241
|
+
|
|
242
|
+
Review the AGENTS.MD and scoped rules above. Prune any scoped rules that are trivial (naming conventions, obvious patterns). Produce the updated AGENTS.MD. Delete, update, or create scoped rules as needed.`;
|
|
243
|
+
return prompt;
|
|
244
|
+
}
|
|
245
|
+
// ── Response parsing ─────────────────────────────────────────
|
|
246
|
+
const SCOPED_DELIMITER = '---SCOPED_RULES---';
|
|
247
|
+
/**
|
|
248
|
+
* Parse the LLM response into AGENTS.md content and optional scoped rules.
|
|
249
|
+
*/
|
|
250
|
+
function parseDreamResponse(raw) {
|
|
251
|
+
const delimIdx = raw.indexOf(SCOPED_DELIMITER);
|
|
252
|
+
let agentsPart;
|
|
253
|
+
let scopedRules = [];
|
|
254
|
+
let deleteSlugs = [];
|
|
255
|
+
if (delimIdx >= 0) {
|
|
256
|
+
agentsPart = raw.slice(0, delimIdx).trim();
|
|
257
|
+
const jsonPart = raw.slice(delimIdx + SCOPED_DELIMITER.length).trim();
|
|
258
|
+
const parsed = parseScopedRulesJson(jsonPart);
|
|
259
|
+
scopedRules = parsed.rules;
|
|
260
|
+
deleteSlugs = parsed.deleteSlugs;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
agentsPart = raw.trim();
|
|
264
|
+
}
|
|
265
|
+
// Strip code fences from AGENTS.md part
|
|
266
|
+
agentsPart = agentsPart.replace(/^```(?:markdown)?\s*\n?/m, '').replace(/\n?```\s*$/m, '').trim();
|
|
267
|
+
if (!agentsPart.endsWith('\n'))
|
|
268
|
+
agentsPart += '\n';
|
|
269
|
+
return { agentsMd: agentsPart, scopedRules, deleteSlugs };
|
|
270
|
+
}
|
|
271
|
+
function parseScopedRulesJson(raw) {
|
|
272
|
+
// Strip code fences if present
|
|
273
|
+
const cleaned = raw.replace(/^```(?:json)?\s*\n?/m, '').replace(/\n?```\s*$/m, '').trim();
|
|
274
|
+
// Try to extract JSON array
|
|
275
|
+
let parsed;
|
|
276
|
+
try {
|
|
277
|
+
parsed = JSON.parse(cleaned);
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
const match = cleaned.match(/\[[\s\S]*\]/);
|
|
281
|
+
if (!match)
|
|
282
|
+
return { rules: [], deleteSlugs: [] };
|
|
283
|
+
try {
|
|
284
|
+
parsed = JSON.parse(match[0]);
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return { rules: [], deleteSlugs: [] };
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (!Array.isArray(parsed))
|
|
291
|
+
return { rules: [], deleteSlugs: [] };
|
|
292
|
+
const deleteSlugs = parsed
|
|
293
|
+
.filter((r) => r.action === 'delete' && r.slug)
|
|
294
|
+
.map((r) => r.slug);
|
|
295
|
+
const rules = parsed
|
|
296
|
+
.filter((r) => r.action !== 'delete' && r.slug && r.description && r.globs?.length && r.content)
|
|
297
|
+
.map((r) => ({
|
|
298
|
+
slug: r.slug,
|
|
299
|
+
description: r.description,
|
|
300
|
+
globs: r.globs,
|
|
301
|
+
content: r.content,
|
|
302
|
+
source: 'dream',
|
|
303
|
+
}));
|
|
304
|
+
return { rules, deleteSlugs };
|
|
305
|
+
}
|
|
306
|
+
// ── Dream cycle entry point ──────────────────────────────────
|
|
307
|
+
async function runDreamCycle(options) {
|
|
308
|
+
const { currentAgentsMd, corrections: corrs, provider, log, scopedRulesContext, userRulesContext, communitySuggestions } = options;
|
|
309
|
+
if (corrs.length === 0 && !scopedRulesContext && !communitySuggestions) {
|
|
310
|
+
return { updatedAgentsMd: currentAgentsMd, changes: [], scopedRules: [], deleteSlugs: [] };
|
|
311
|
+
}
|
|
312
|
+
log?.info(`Dream cycle: processing ${corrs.length} correction${corrs.length === 1 ? '' : 's'}…`);
|
|
313
|
+
const messages = [
|
|
314
|
+
{ role: 'system', content: DREAM_SYSTEM },
|
|
315
|
+
{ role: 'user', content: buildDreamUserPrompt(currentAgentsMd, corrs, scopedRulesContext, userRulesContext, communitySuggestions) },
|
|
316
|
+
];
|
|
317
|
+
const response = await (0, optimizer_1.withRetry)(() => provider.chat(messages), { baseDelayMs: 1000, maxDelayMs: 8000, maxRetries: 2 });
|
|
318
|
+
const { agentsMd, scopedRules, deleteSlugs } = parseDreamResponse(response);
|
|
319
|
+
// Build change summary
|
|
320
|
+
const confirmed = corrs.filter((c) => c.action === 'confirm').length;
|
|
321
|
+
const dismissed = corrs.filter((c) => c.action === 'dismiss').length;
|
|
322
|
+
const changes = [];
|
|
323
|
+
if (confirmed > 0)
|
|
324
|
+
changes.push(`${confirmed} confirmed`);
|
|
325
|
+
if (dismissed > 0)
|
|
326
|
+
changes.push(`${dismissed} dismissed`);
|
|
327
|
+
if (scopedRules.length > 0)
|
|
328
|
+
changes.push(`${scopedRules.length} scoped`);
|
|
329
|
+
if (deleteSlugs.length > 0)
|
|
330
|
+
changes.push(`${deleteSlugs.length} pruned`);
|
|
331
|
+
log?.info(`Dream cycle complete: ${changes.join(', ')}`);
|
|
332
|
+
return { updatedAgentsMd: agentsMd, changes, scopedRules, deleteSlugs };
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=dreamCycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dreamCycle.js","sourceRoot":"","sources":["../src/dreamCycle.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CH,sCAEC;AAED,wCAEC;AAED,kDAEC;AAED,kCAEC;AAED,sCAEC;AAGD,4CAEC;AAID,wCAQC;AAED,wCAIC;AAID,8CAyBC;AAID,8CAYC;AAED,0CAYC;AAED,8CAcC;AAgGD,gDAuBC;AAyCD,sCAwCC;AArWD,uCAAyB;AACzB,2CAA6B;AAE7B,qDAAkD;AAuBlD,gEAAgE;AAEhE,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,QAAQ,GAAG,aAAa,CAAC;AAC/B,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC,gEAAgE;AAEnD,QAAA,aAAa,GAAG,6BAA6B,CAAC;AAC9C,QAAA,WAAW,GAAG,8BAA8B,CAAC;AAE1D,gEAAgE;AAEhE,MAAM,WAAW,GAAiB,EAAE,CAAC;AAErC,SAAgB,aAAa,CAAC,MAA6B,EAAE,UAA4B;IACvF,WAAW,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,SAAgB,cAAc;IAC5B,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,mBAAmB;IACjC,OAAO,WAAW,CAAC,MAAM,CAAC;AAC5B,CAAC;AAED,SAAgB,WAAW;IACzB,OAAO,WAAW,CAAC,MAAM,IAAI,eAAe,CAAC;AAC/C,CAAC;AAED,SAAgB,aAAa;IAC3B,WAAW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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;IACrE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,YAAY,CAAC,CAAC;IAC1D,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,YAAY,CAAC,CAAC;IAC1D,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC;IACzE,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,CAAC;IAEzE,GAAG,EAAE,IAAI,CAAC,yBAAyB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAC1E,CAAC"}
|
package/dist/kbBuilder.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* In-memory KB builder — constructs the knowledge base content string
|
|
3
|
-
* without writing to disk (unless --kb flag is used).
|
|
2
|
+
* In-memory KB builder — constructs the knowledge base content string.
|
|
4
3
|
*
|
|
5
4
|
* Combines architecture + map + context emitter outputs into a single
|
|
6
5
|
* KB string that can be fed to the optimizer.
|
package/dist/kbBuilder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kbBuilder.d.ts","sourceRoot":"","sources":["../src/kbBuilder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"kbBuilder.d.ts","sourceRoot":"","sources":["../src/kbBuilder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,kBAAkB,CAAC;AAOtE;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,EACpB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAiER"}
|
package/dist/kbBuilder.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* In-memory KB builder — constructs the knowledge base content string
|
|
4
|
-
* without writing to disk (unless --kb flag is used).
|
|
3
|
+
* In-memory KB builder — constructs the knowledge base content string.
|
|
5
4
|
*
|
|
6
5
|
* Combines architecture + map + context emitter outputs into a single
|
|
7
6
|
* KB string that can be fed to the optimizer.
|
package/dist/kbBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kbBuilder.js","sourceRoot":"","sources":["../src/kbBuilder.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"kbBuilder.js","sourceRoot":"","sources":["../src/kbBuilder.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcH,wCAqEC;AAjFD,2CAA6B;AAE7B,mDAI8B;AAE9B;;;GAGG;AACH,SAAgB,cAAc,CAC5B,KAAoB,EACpB,aAAqB,EACrB,YAAiC;IAEjC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE7C,mDAAmD;IACnD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmD,CAAC;IAC3E,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACrC,uBAAuB;QACvB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,EAA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C,MAAM,CAAC;QACjF,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC;QACjF,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;QACpB,aAAa,EAAE,CAAC,CAAC,aAAa,IAAI,KAAK;KACxC,CAAC,CAAC,CAAC;IAEJ,MAAM,YAAY,GAAG,IAAA,mCAAwB,EAAC;QAC5C,KAAK;QACL,OAAO;QACP,QAAQ;QACR,gBAAgB,EAAE,oBAAoB;QACtC,aAAa;QACb,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,IAAA,0BAAe,EAAC;QACjC,KAAK;QACL,OAAO;QACP,QAAQ;QACR,QAAQ,EAAE,IAAI;QACd,gBAAgB,EAAE,oBAAoB;QACtC,aAAa;QACb,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,8BAAmB,EAAC;QAClC,KAAK;QACL,QAAQ;QACR,gBAAgB,EAAE,oBAAoB;QACtC,aAAa;QACb,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,GAAG,YAAY,cAAc,UAAU,cAAc,OAAO,EAAE,CAAC;AACxE,CAAC"}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* aspectcode CLI — main entry point.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Subcommands: login, logout, whoami.
|
|
5
|
+
* Default (no subcommand): `aspectcode [flags]` runs the pipeline:
|
|
5
6
|
* analyze → build KB → ingest tool files → optimize → write AGENTS.md → watch
|
|
6
7
|
*/
|
|
7
8
|
import type { CliFlags } from './cli';
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAsBtC,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,QAAQ,CAyClD;AA8PD,mDAAmD;AACnD,wBAAgB,GAAG,IAAI,IAAI,CAK1B"}
|
package/dist/main.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* aspectcode CLI — main entry point.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Subcommands: login, logout, whoami.
|
|
6
|
+
* Default (no subcommand): `aspectcode [flags]` runs the pipeline:
|
|
6
7
|
* analyze → build KB → ingest tool files → optimize → write AGENTS.md → watch
|
|
7
8
|
*/
|
|
8
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -42,12 +43,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
43
|
exports.parseArgs = parseArgs;
|
|
43
44
|
exports.run = run;
|
|
44
45
|
const path = __importStar(require("path"));
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const os = __importStar(require("os"));
|
|
48
|
+
const child_process_1 = require("child_process");
|
|
45
49
|
const cli_1 = require("./cli");
|
|
46
50
|
const logger_1 = require("./logger");
|
|
47
51
|
const version_1 = require("./version");
|
|
48
52
|
const pipeline_1 = require("./pipeline");
|
|
49
53
|
const inkLogger_1 = require("./ui/inkLogger");
|
|
50
54
|
const store_1 = require("./ui/store");
|
|
55
|
+
const auth_1 = require("./auth");
|
|
51
56
|
// ── Build lookup tables from FLAG_DEFS ───────────────────────
|
|
52
57
|
/** Map --long-name → FlagDef */
|
|
53
58
|
const longMap = new Map(cli_1.FLAG_DEFS.map((d) => [`--${d.name}`, d]));
|
|
@@ -60,11 +65,11 @@ function parseArgs(argv) {
|
|
|
60
65
|
version: false,
|
|
61
66
|
verbose: false,
|
|
62
67
|
quiet: false,
|
|
63
|
-
kb: false,
|
|
64
68
|
dryRun: false,
|
|
65
69
|
once: false,
|
|
66
70
|
noColor: false,
|
|
67
71
|
compact: false,
|
|
72
|
+
background: false,
|
|
68
73
|
};
|
|
69
74
|
const args = argv.slice(2); // skip node + script
|
|
70
75
|
let i = 0;
|
|
@@ -109,18 +114,26 @@ ${logger_1.fmt.bold('aspectcode')} — generate AGENTS.md for your codebase
|
|
|
109
114
|
|
|
110
115
|
${logger_1.fmt.bold('USAGE')}
|
|
111
116
|
aspectcode [options]
|
|
117
|
+
aspectcode <command>
|
|
112
118
|
|
|
113
119
|
Analyzes your codebase, builds a knowledge base, reads existing AI tool
|
|
114
120
|
instruction files for context, generates AGENTS.md via LLM (when API key
|
|
115
121
|
is available), and watches for changes.
|
|
116
122
|
|
|
123
|
+
${logger_1.fmt.bold('COMMANDS')}
|
|
124
|
+
login ${logger_1.fmt.dim('# Authenticate via browser (Google OAuth)')}
|
|
125
|
+
logout ${logger_1.fmt.dim('# Clear stored credentials')}
|
|
126
|
+
whoami ${logger_1.fmt.dim('# Show current logged-in user')}
|
|
127
|
+
upgrade ${logger_1.fmt.dim('# Open Pro upgrade page in browser')}
|
|
128
|
+
usage ${logger_1.fmt.dim('# Show current tier and token usage')}
|
|
129
|
+
|
|
117
130
|
${logger_1.fmt.bold('OPTIONS')}
|
|
118
131
|
${optionLines.join('\n')}
|
|
119
132
|
|
|
120
133
|
${logger_1.fmt.bold('EXAMPLES')}
|
|
121
134
|
aspectcode ${logger_1.fmt.dim('# watch & auto-update AGENTS.md')}
|
|
135
|
+
aspectcode login ${logger_1.fmt.dim('# authenticate with your account')}
|
|
122
136
|
aspectcode --once ${logger_1.fmt.dim('# run once then exit')}
|
|
123
|
-
aspectcode --once --kb ${logger_1.fmt.dim('# also write kb.md')}
|
|
124
137
|
aspectcode --once --dry-run ${logger_1.fmt.dim('# preview without writing')}
|
|
125
138
|
aspectcode --provider openai ${logger_1.fmt.dim('# force specific LLM provider')}
|
|
126
139
|
aspectcode --compact ${logger_1.fmt.dim('# minimal dashboard layout')}
|
|
@@ -133,8 +146,92 @@ function parseFloatFlag(value, min, max) {
|
|
|
133
146
|
const n = parseFloat(value);
|
|
134
147
|
return Number.isFinite(n) && n >= min && n <= max ? n : undefined;
|
|
135
148
|
}
|
|
149
|
+
// ── Background: spawn in a new terminal ──────────────────────
|
|
150
|
+
/** Spawn aspectcode in a new terminal window. Returns true if successful. */
|
|
151
|
+
function spawnInTerminal() {
|
|
152
|
+
const binPath = path.resolve(__dirname, '..', 'bin', 'aspectcode.js');
|
|
153
|
+
const forwardedArgs = process.argv.slice(2).filter((a) => a !== '--background');
|
|
154
|
+
const nodeExe = process.execPath;
|
|
155
|
+
try {
|
|
156
|
+
let child;
|
|
157
|
+
if (process.platform === 'win32') {
|
|
158
|
+
// Write a temp .bat file to avoid quoting hell with spaces in paths.
|
|
159
|
+
// cmd /k + start can't reliably handle "C:\Program Files\..." nesting.
|
|
160
|
+
const batPath = path.join(os.tmpdir(), `aspectcode-bg-${Date.now()}.bat`);
|
|
161
|
+
const argsStr = forwardedArgs.length > 0 ? ' ' + forwardedArgs.join(' ') : '';
|
|
162
|
+
fs.writeFileSync(batPath, `@echo off\r\n"${nodeExe}" "${binPath}"${argsStr}\r\n`);
|
|
163
|
+
child = (0, child_process_1.spawn)('cmd.exe', ['/c', 'start', 'cmd.exe', '/k', batPath], {
|
|
164
|
+
detached: true,
|
|
165
|
+
stdio: 'ignore',
|
|
166
|
+
});
|
|
167
|
+
// Clean up bat file after a delay (the new terminal has already read it)
|
|
168
|
+
setTimeout(() => { try {
|
|
169
|
+
fs.unlinkSync(batPath);
|
|
170
|
+
}
|
|
171
|
+
catch { /* ignore */ } }, 5000);
|
|
172
|
+
}
|
|
173
|
+
else if (process.platform === 'darwin') {
|
|
174
|
+
const escaped = [nodeExe, binPath, ...forwardedArgs]
|
|
175
|
+
.map((a) => a.replace(/\\/g, '\\\\').replace(/"/g, '\\"'))
|
|
176
|
+
.join(' ');
|
|
177
|
+
child = (0, child_process_1.spawn)('osascript', ['-e', `tell app "Terminal" to do script "${escaped}"`], {
|
|
178
|
+
detached: true,
|
|
179
|
+
stdio: 'ignore',
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// Linux: try gnome-terminal, fall back to xterm
|
|
184
|
+
try {
|
|
185
|
+
child = (0, child_process_1.spawn)('gnome-terminal', ['--', nodeExe, binPath, ...forwardedArgs], {
|
|
186
|
+
detached: true,
|
|
187
|
+
stdio: 'ignore',
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
child = (0, child_process_1.spawn)('xterm', ['-e', nodeExe, binPath, ...forwardedArgs], {
|
|
192
|
+
detached: true,
|
|
193
|
+
stdio: 'ignore',
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
child.unref();
|
|
198
|
+
console.log('◆ aspect code running in background');
|
|
199
|
+
process.exitCode = cli_1.ExitCode.OK;
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
console.log('◆ could not open terminal window — running headless');
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
136
207
|
// ── Main ─────────────────────────────────────────────────────
|
|
137
208
|
async function main() {
|
|
209
|
+
// Handle subcommands
|
|
210
|
+
const firstArg = process.argv[2];
|
|
211
|
+
if (firstArg === 'logout') {
|
|
212
|
+
await (0, auth_1.logoutCommand)();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (firstArg === 'whoami') {
|
|
216
|
+
await (0, auth_1.whoamiCommand)();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (firstArg === 'upgrade') {
|
|
220
|
+
await (0, auth_1.upgradeCommand)();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (firstArg === 'usage') {
|
|
224
|
+
await (0, auth_1.usageCommand)();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// Login then continue to pipeline
|
|
228
|
+
if (firstArg === 'login') {
|
|
229
|
+
await (0, auth_1.loginCommand)(process.argv.slice(3));
|
|
230
|
+
if (process.exitCode)
|
|
231
|
+
return; // login failed
|
|
232
|
+
// Strip 'login' (and optional code arg) from argv before parsing flags
|
|
233
|
+
process.argv = [process.argv[0], process.argv[1]];
|
|
234
|
+
}
|
|
138
235
|
const flags = parseArgs(process.argv);
|
|
139
236
|
// Global flags that exit early
|
|
140
237
|
if (flags.version) {
|
|
@@ -147,6 +244,48 @@ async function main() {
|
|
|
147
244
|
process.exitCode = cli_1.ExitCode.OK;
|
|
148
245
|
return;
|
|
149
246
|
}
|
|
247
|
+
// Background mode: spawn in a new terminal window and exit immediately
|
|
248
|
+
if (flags.background) {
|
|
249
|
+
if (spawnInTerminal())
|
|
250
|
+
return;
|
|
251
|
+
// Spawn failed — fall through to run headless in this process
|
|
252
|
+
flags.background = false;
|
|
253
|
+
}
|
|
254
|
+
// Require login for the pipeline
|
|
255
|
+
if (!(0, auth_1.loadCredentials)()) {
|
|
256
|
+
console.log(`${logger_1.fmt.bold('Login required.')} Press any key to open browser login...`);
|
|
257
|
+
await new Promise((resolve) => {
|
|
258
|
+
process.stdin.setRawMode?.(true);
|
|
259
|
+
process.stdin.resume();
|
|
260
|
+
process.stdin.once('data', () => {
|
|
261
|
+
process.stdin.setRawMode?.(false);
|
|
262
|
+
process.stdin.pause();
|
|
263
|
+
resolve();
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
await (0, auth_1.loginCommand)([]);
|
|
267
|
+
if (!(0, auth_1.loadCredentials)()) {
|
|
268
|
+
process.exitCode = cli_1.ExitCode.ERROR;
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// Check for updates (non-blocking — runs sync but fast, 5s timeout)
|
|
273
|
+
try {
|
|
274
|
+
const { checkForUpdate } = await Promise.resolve().then(() => __importStar(require('./updateChecker')));
|
|
275
|
+
const updateResult = checkForUpdate();
|
|
276
|
+
if (updateResult) {
|
|
277
|
+
if (updateResult.updated) {
|
|
278
|
+
// Re-exec with the new version
|
|
279
|
+
console.log(`✓ ${updateResult.message} — restarting...`);
|
|
280
|
+
const { execSync } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
|
281
|
+
execSync(`aspectcode ${process.argv.slice(2).join(' ')}`, { stdio: 'inherit' });
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
// Store message for dashboard display
|
|
285
|
+
globalThis.__updateMessage = updateResult.message;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch { /* update check is best-effort */ }
|
|
150
289
|
if (flags.noColor) {
|
|
151
290
|
(0, logger_1.disableColor)();
|
|
152
291
|
}
|
|
@@ -155,10 +294,12 @@ async function main() {
|
|
|
155
294
|
flags.temperature = parseFloatFlag(flags.temperature, 0, 2);
|
|
156
295
|
}
|
|
157
296
|
const root = path.resolve(flags.root ?? process.cwd());
|
|
158
|
-
// Resolve ownership BEFORE mounting the ink dashboard.
|
|
159
|
-
// selectPrompt
|
|
160
|
-
const ownership = await (0, pipeline_1.
|
|
161
|
-
const
|
|
297
|
+
// Resolve ownership + platforms BEFORE mounting the ink dashboard.
|
|
298
|
+
// selectPrompt / multiSelectPrompt use raw stdin which conflicts with ink's useInput.
|
|
299
|
+
const { ownership, generate } = await (0, pipeline_1.resolveRunMode)(root);
|
|
300
|
+
const { resolvePlatforms } = await Promise.resolve().then(() => __importStar(require('./pipeline')));
|
|
301
|
+
const activePlatforms = await resolvePlatforms(root);
|
|
302
|
+
const useDashboard = !flags.quiet && !flags.noColor && !flags.background && process.stdout.isTTY === true;
|
|
162
303
|
let log;
|
|
163
304
|
let spin;
|
|
164
305
|
let unmount;
|
|
@@ -193,7 +334,7 @@ async function main() {
|
|
|
193
334
|
spin = (msg) => (0, logger_1.createSpinner)(msg, { quiet: flags.quiet });
|
|
194
335
|
}
|
|
195
336
|
try {
|
|
196
|
-
process.exitCode = await (0, pipeline_1.runPipeline)({ root, flags, log, spin, ownership });
|
|
337
|
+
process.exitCode = await (0, pipeline_1.runPipeline)({ root, flags, log, spin, ownership, generate, platforms: activePlatforms });
|
|
197
338
|
}
|
|
198
339
|
finally {
|
|
199
340
|
if (unmount)
|