@a-company/paradigm 1.5.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 +142 -0
- package/dist/accept-orchestration-CWZNCGZX.js +188 -0
- package/dist/agents-suggest-35LIQKDH.js +83 -0
- package/dist/aggregate-W7Q6VIM2.js +88 -0
- package/dist/auto-IU7VN55K.js +470 -0
- package/dist/beacon-B47XSTL7.js +251 -0
- package/dist/chunk-2M6OSOIG.js +1302 -0
- package/dist/chunk-4NCFWYGG.js +110 -0
- package/dist/chunk-5C4SGQKH.js +705 -0
- package/dist/chunk-5GOA7WYD.js +1095 -0
- package/dist/chunk-5JGJACDU.js +37 -0
- package/dist/chunk-6QC3YGB6.js +114 -0
- package/dist/chunk-753RICFF.js +325 -0
- package/dist/chunk-AD2LSCHB.js +1595 -0
- package/dist/chunk-CHSHON3O.js +669 -0
- package/dist/chunk-ELLR7WP6.js +3175 -0
- package/dist/chunk-ILOWBJRC.js +12 -0
- package/dist/chunk-IRKUEJVW.js +405 -0
- package/dist/chunk-MC7XC7XQ.js +533 -0
- package/dist/chunk-MO4EEYFW.js +38 -0
- package/dist/chunk-MQWH7PFI.js +13366 -0
- package/dist/chunk-N6PJAPDE.js +364 -0
- package/dist/chunk-PBHIFAL4.js +259 -0
- package/dist/chunk-PMXRGPRQ.js +305 -0
- package/dist/chunk-PW2EXJQT.js +689 -0
- package/dist/chunk-TAP5N3HH.js +245 -0
- package/dist/chunk-THFVK5AE.js +148 -0
- package/dist/chunk-UM54F7G5.js +1533 -0
- package/dist/chunk-UUZ2DMG5.js +185 -0
- package/dist/chunk-WS5KM7OL.js +780 -0
- package/dist/chunk-YDNKXH4Z.js +2316 -0
- package/dist/chunk-YO6DVTL7.js +99 -0
- package/dist/claude-SUYNN72C.js +362 -0
- package/dist/claude-cli-OF43XAO3.js +276 -0
- package/dist/claude-code-PW6SKD2M.js +126 -0
- package/dist/claude-code-teams-JLZ5IXB6.js +199 -0
- package/dist/constellation-K3CIQCHI.js +225 -0
- package/dist/cost-AEK6R7HK.js +174 -0
- package/dist/cost-KYXIQ62X.js +93 -0
- package/dist/cursor-cli-IHJMPRCW.js +269 -0
- package/dist/cursorrules-KI5QWHIX.js +84 -0
- package/dist/diff-AJJ5H6HV.js +125 -0
- package/dist/dist-7MPIRMTZ-IOQOREMZ.js +10866 -0
- package/dist/dist-NHJQVVUW.js +68 -0
- package/dist/dist-ZEMSQV74.js +20 -0
- package/dist/doctor-6Y6L6HEB.js +11 -0
- package/dist/echo-VYZW3OTT.js +248 -0
- package/dist/export-R4FJ5NOH.js +38 -0
- package/dist/history-EVO3L6SC.js +277 -0
- package/dist/hooks-MBWE4ILT.js +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +568 -0
- package/dist/lint-HXKTWRNO.js +316 -0
- package/dist/manual-Y3QOXWYA.js +204 -0
- package/dist/mcp.js +14745 -0
- package/dist/orchestrate-4ZH5GUQH.js +323 -0
- package/dist/probe-OYCP4JYG.js +151 -0
- package/dist/promote-Z52ZJTJU.js +181 -0
- package/dist/providers-4PGPZEWP.js +104 -0
- package/dist/remember-6VZ74B7E.js +77 -0
- package/dist/ripple-SBQOSTZD.js +215 -0
- package/dist/sentinel-LCFD56OJ.js +43 -0
- package/dist/server-F5ITNK6T.js +9846 -0
- package/dist/server-T6WIFYRQ.js +16076 -0
- package/dist/setup-DF4F3ICN.js +25 -0
- package/dist/setup-JHBPZAG7.js +296 -0
- package/dist/shift-HKIAP4ZN.js +226 -0
- package/dist/snapshot-GTVPRYZG.js +62 -0
- package/dist/spawn-BJRQA2NR.js +196 -0
- package/dist/summary-H6J6N6PJ.js +140 -0
- package/dist/switch-6EANJ7O6.js +232 -0
- package/dist/sync-BEOCW7TZ.js +11 -0
- package/dist/team-NWP2KJAB.js +32 -0
- package/dist/test-MA5TWJQV.js +934 -0
- package/dist/thread-JCJVRUQR.js +258 -0
- package/dist/triage-ETVXXFMV.js +1880 -0
- package/dist/tutorial-L5Q3ZDHK.js +666 -0
- package/dist/university-R2WDQLSI.js +40 -0
- package/dist/upgrade-5B3YGGC6.js +550 -0
- package/dist/validate-F3YHBCRZ.js +39 -0
- package/dist/validate-QEEY6KFS.js +64 -0
- package/dist/watch-4LT4O6K7.js +123 -0
- package/dist/watch-6IIWPWDN.js +111 -0
- package/dist/wisdom-LRM4FFCH.js +319 -0
- package/package.json +68 -0
- package/templates/paradigm/config.yaml +175 -0
- package/templates/paradigm/docs/commands.md +727 -0
- package/templates/paradigm/docs/decisions/000-template.md +47 -0
- package/templates/paradigm/docs/decisions/README.md +26 -0
- package/templates/paradigm/docs/error-patterns.md +215 -0
- package/templates/paradigm/docs/patterns.md +358 -0
- package/templates/paradigm/docs/queries.md +200 -0
- package/templates/paradigm/docs/troubleshooting.md +477 -0
- package/templates/paradigm/echoes.yaml +25 -0
- package/templates/paradigm/prompts/add-feature.md +152 -0
- package/templates/paradigm/prompts/add-gate.md +117 -0
- package/templates/paradigm/prompts/debug-auth.md +174 -0
- package/templates/paradigm/prompts/implement-ftux.md +722 -0
- package/templates/paradigm/prompts/implement-sandbox.md +651 -0
- package/templates/paradigm/prompts/read-docs.md +84 -0
- package/templates/paradigm/prompts/refactor.md +106 -0
- package/templates/paradigm/prompts/run-e2e-tests.md +340 -0
- package/templates/paradigm/prompts/trace-flow.md +202 -0
- package/templates/paradigm/prompts/validate-portals.md +279 -0
- package/templates/paradigm/specs/context-tracking.md +200 -0
- package/templates/paradigm/specs/context.md +461 -0
- package/templates/paradigm/specs/disciplines.md +413 -0
- package/templates/paradigm/specs/history.md +339 -0
- package/templates/paradigm/specs/logger.md +303 -0
- package/templates/paradigm/specs/navigator.md +236 -0
- package/templates/paradigm/specs/purpose.md +265 -0
- package/templates/paradigm/specs/scan.md +177 -0
- package/templates/paradigm/specs/symbols.md +451 -0
- package/templates/paradigm/specs/wisdom.md +294 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
PREFIX_TO_TYPE,
|
|
4
|
+
SYMBOL_PREFIXES,
|
|
5
|
+
addConnection,
|
|
6
|
+
addPremiseNode,
|
|
7
|
+
aggregateFromDirectory,
|
|
8
|
+
aggregateFromPremise,
|
|
9
|
+
buildSymbolIndex,
|
|
10
|
+
createEmptyPremiseFile,
|
|
11
|
+
createSnapshot,
|
|
12
|
+
createSymbolIndex,
|
|
13
|
+
createSymbolString,
|
|
14
|
+
getAllSymbols,
|
|
15
|
+
getAllTags,
|
|
16
|
+
getAutocompleteSuggestions,
|
|
17
|
+
getDefaultPremiseContent,
|
|
18
|
+
getReferencesFrom,
|
|
19
|
+
getReferencesTo,
|
|
20
|
+
getSymbol,
|
|
21
|
+
getSymbolById,
|
|
22
|
+
getSymbolCounts,
|
|
23
|
+
getSymbolsBySource,
|
|
24
|
+
getSymbolsByTag,
|
|
25
|
+
getSymbolsByType,
|
|
26
|
+
isValidSymbol,
|
|
27
|
+
parsePremiseContent,
|
|
28
|
+
parsePremiseFile,
|
|
29
|
+
parseSymbol,
|
|
30
|
+
searchSymbols,
|
|
31
|
+
serializePremiseFile,
|
|
32
|
+
updateNodePosition
|
|
33
|
+
} from "./chunk-5C4SGQKH.js";
|
|
34
|
+
import "./chunk-PW2EXJQT.js";
|
|
35
|
+
import "./chunk-IRKUEJVW.js";
|
|
36
|
+
import "./chunk-MO4EEYFW.js";
|
|
37
|
+
export {
|
|
38
|
+
PREFIX_TO_TYPE,
|
|
39
|
+
SYMBOL_PREFIXES,
|
|
40
|
+
addConnection,
|
|
41
|
+
addPremiseNode,
|
|
42
|
+
aggregateFromDirectory,
|
|
43
|
+
aggregateFromPremise,
|
|
44
|
+
buildSymbolIndex,
|
|
45
|
+
createEmptyPremiseFile,
|
|
46
|
+
createSnapshot,
|
|
47
|
+
createSymbolIndex,
|
|
48
|
+
createSymbolString,
|
|
49
|
+
getAllSymbols,
|
|
50
|
+
getAllTags,
|
|
51
|
+
getAutocompleteSuggestions,
|
|
52
|
+
getDefaultPremiseContent,
|
|
53
|
+
getReferencesFrom,
|
|
54
|
+
getReferencesTo,
|
|
55
|
+
getSymbol,
|
|
56
|
+
getSymbolById,
|
|
57
|
+
getSymbolCounts,
|
|
58
|
+
getSymbolsBySource,
|
|
59
|
+
getSymbolsByTag,
|
|
60
|
+
getSymbolsByType,
|
|
61
|
+
isValidSymbol,
|
|
62
|
+
parsePremiseContent,
|
|
63
|
+
parsePremiseFile,
|
|
64
|
+
parseSymbol,
|
|
65
|
+
searchSymbols,
|
|
66
|
+
serializePremiseFile,
|
|
67
|
+
updateNodePosition
|
|
68
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
findGateFiles,
|
|
4
|
+
formatValidationResult,
|
|
5
|
+
getDefaultGateConfig,
|
|
6
|
+
parseGateConfig,
|
|
7
|
+
parseGateFile,
|
|
8
|
+
serializeGateConfig,
|
|
9
|
+
validateGateConfig
|
|
10
|
+
} from "./chunk-IRKUEJVW.js";
|
|
11
|
+
import "./chunk-MO4EEYFW.js";
|
|
12
|
+
export {
|
|
13
|
+
findGateFiles,
|
|
14
|
+
formatValidationResult,
|
|
15
|
+
getDefaultGateConfig,
|
|
16
|
+
parseGateConfig,
|
|
17
|
+
parseGateFile,
|
|
18
|
+
serializeGateConfig,
|
|
19
|
+
validateGateConfig
|
|
20
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
log
|
|
4
|
+
} from "./chunk-4NCFWYGG.js";
|
|
5
|
+
import "./chunk-MO4EEYFW.js";
|
|
6
|
+
|
|
7
|
+
// src/commands/echo.ts
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
import chalk from "chalk";
|
|
11
|
+
var ECHOES_TEMPLATE = `# Echoes - Error to Symbol Mapping
|
|
12
|
+
# When errors occur, they echo back to their source symbol.
|
|
13
|
+
# Run \`paradigm echo ERROR_CODE\` to look up context.
|
|
14
|
+
|
|
15
|
+
version: "1.0"
|
|
16
|
+
|
|
17
|
+
errors:
|
|
18
|
+
# Example error mapping
|
|
19
|
+
AUTH_REQUIRED:
|
|
20
|
+
symbol: "^authenticated"
|
|
21
|
+
location: "src/middleware/auth.ts"
|
|
22
|
+
ripple:
|
|
23
|
+
- "@checkout"
|
|
24
|
+
- "@profile"
|
|
25
|
+
- "@settings"
|
|
26
|
+
resolution: "Ensure user token is passed in request headers"
|
|
27
|
+
|
|
28
|
+
# Add your error mappings below
|
|
29
|
+
# ERROR_CODE:
|
|
30
|
+
# symbol: "^portal-name" # or signal: "!signal-name"
|
|
31
|
+
# location: "path/to/file.ts"
|
|
32
|
+
# ripple:
|
|
33
|
+
# - "@feature1"
|
|
34
|
+
# - "@feature2"
|
|
35
|
+
# resolution: "How to fix this error"
|
|
36
|
+
`;
|
|
37
|
+
function parseEchoes(content) {
|
|
38
|
+
const data = {
|
|
39
|
+
version: "1.0",
|
|
40
|
+
errors: {}
|
|
41
|
+
};
|
|
42
|
+
const lines = content.split("\n");
|
|
43
|
+
let currentError = null;
|
|
44
|
+
let currentEntry = {};
|
|
45
|
+
let inRipple = false;
|
|
46
|
+
for (const line of lines) {
|
|
47
|
+
if (line.trim().startsWith("#") || line.trim() === "") continue;
|
|
48
|
+
const versionMatch = line.match(/^version:\s*"?([^"]+)"?/);
|
|
49
|
+
if (versionMatch) {
|
|
50
|
+
data.version = versionMatch[1];
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (line.match(/^errors:\s*$/)) continue;
|
|
54
|
+
const errorKeyMatch = line.match(/^ ([A-Z_][A-Z0-9_]*):\s*$/);
|
|
55
|
+
if (errorKeyMatch) {
|
|
56
|
+
if (currentError && Object.keys(currentEntry).length > 0) {
|
|
57
|
+
data.errors[currentError] = currentEntry;
|
|
58
|
+
}
|
|
59
|
+
currentError = errorKeyMatch[1];
|
|
60
|
+
currentEntry = {};
|
|
61
|
+
inRipple = false;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (currentError) {
|
|
65
|
+
const symbolMatch = line.match(/^\s{4}symbol:\s*"?([^"]+)"?/);
|
|
66
|
+
if (symbolMatch) {
|
|
67
|
+
currentEntry.symbol = symbolMatch[1];
|
|
68
|
+
inRipple = false;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const signalMatch = line.match(/^\s{4}signal:\s*"?([^"]+)"?/);
|
|
72
|
+
if (signalMatch) {
|
|
73
|
+
currentEntry.signal = signalMatch[1];
|
|
74
|
+
inRipple = false;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const locationMatch = line.match(/^\s{4}location:\s*"?([^"]+)"?/);
|
|
78
|
+
if (locationMatch) {
|
|
79
|
+
currentEntry.location = locationMatch[1];
|
|
80
|
+
inRipple = false;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const resolutionMatch = line.match(/^\s{4}resolution:\s*"?([^"]+)"?/);
|
|
84
|
+
if (resolutionMatch) {
|
|
85
|
+
currentEntry.resolution = resolutionMatch[1];
|
|
86
|
+
inRipple = false;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (line.match(/^\s{4}ripple:\s*$/)) {
|
|
90
|
+
currentEntry.ripple = [];
|
|
91
|
+
inRipple = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (inRipple) {
|
|
95
|
+
const rippleMatch = line.match(/^\s{6}-\s*"?([^"]+)"?/);
|
|
96
|
+
if (rippleMatch) {
|
|
97
|
+
if (!currentEntry.ripple) currentEntry.ripple = [];
|
|
98
|
+
currentEntry.ripple.push(rippleMatch[1]);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (currentError && Object.keys(currentEntry).length > 0) {
|
|
105
|
+
data.errors[currentError] = currentEntry;
|
|
106
|
+
}
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
async function echoCommand(errorCode, targetPath, options = {}) {
|
|
110
|
+
const cwd = process.cwd();
|
|
111
|
+
const absolutePath = targetPath ? path.resolve(cwd, targetPath) : cwd;
|
|
112
|
+
const echoesPath = path.join(absolutePath, ".paradigm", "echoes.yaml");
|
|
113
|
+
log.command("echo").debug("Looking up error code", { errorCode });
|
|
114
|
+
if (!fs.existsSync(echoesPath)) {
|
|
115
|
+
if (options.json) {
|
|
116
|
+
console.log(JSON.stringify({ found: false, error: "No echoes.yaml found" }, null, 2));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
log.command("echo").warn("No echoes.yaml found");
|
|
120
|
+
console.log(chalk.yellow("\n\u{1F4E2} No echoes.yaml found.\n"));
|
|
121
|
+
console.log(chalk.gray(" Run `paradigm echo --init` to create one.\n"));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const content = fs.readFileSync(echoesPath, "utf8");
|
|
125
|
+
const data = parseEchoes(content);
|
|
126
|
+
log.component("echoes-parser").debug("Echoes file parsed", { count: Object.keys(data.errors).length });
|
|
127
|
+
const entry = data.errors[errorCode.toUpperCase()];
|
|
128
|
+
if (!entry) {
|
|
129
|
+
log.command("echo").warn("Error code not found", { errorCode });
|
|
130
|
+
if (options.json) {
|
|
131
|
+
console.log(JSON.stringify({
|
|
132
|
+
found: false,
|
|
133
|
+
errorCode: errorCode.toUpperCase(),
|
|
134
|
+
available: Object.keys(data.errors)
|
|
135
|
+
}, null, 2));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
console.log(chalk.yellow(`
|
|
139
|
+
\u{1F4E2} No echo found for: ${errorCode}
|
|
140
|
+
`));
|
|
141
|
+
const available = Object.keys(data.errors);
|
|
142
|
+
if (available.length > 0) {
|
|
143
|
+
console.log(chalk.gray(" Available error codes:"));
|
|
144
|
+
for (const code of available.slice(0, 10)) {
|
|
145
|
+
const e = data.errors[code];
|
|
146
|
+
const symbolInfo = e.symbol || e.signal || "";
|
|
147
|
+
console.log(chalk.gray(` ${code} \u2192 ${symbolInfo}`));
|
|
148
|
+
}
|
|
149
|
+
if (available.length > 10) {
|
|
150
|
+
console.log(chalk.gray(` ... and ${available.length - 10} more`));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
console.log("");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
log.command("echo").success("Error code found", { errorCode, hasSymbol: !!entry.symbol, hasResolution: !!entry.resolution });
|
|
157
|
+
if (options.json) {
|
|
158
|
+
console.log(JSON.stringify({
|
|
159
|
+
found: true,
|
|
160
|
+
errorCode: errorCode.toUpperCase(),
|
|
161
|
+
...entry
|
|
162
|
+
}, null, 2));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
console.log(chalk.blue(`
|
|
166
|
+
\u{1F4E2} Echo: ${chalk.cyan(errorCode)}
|
|
167
|
+
`));
|
|
168
|
+
console.log(chalk.gray("\u2500".repeat(50)));
|
|
169
|
+
if (entry.symbol) {
|
|
170
|
+
console.log(` Symbol: ${chalk.red(entry.symbol)}`);
|
|
171
|
+
}
|
|
172
|
+
if (entry.signal) {
|
|
173
|
+
console.log(` Signal: ${chalk.yellow(entry.signal)}`);
|
|
174
|
+
}
|
|
175
|
+
if (entry.location) {
|
|
176
|
+
console.log(` Location: ${chalk.gray(entry.location)}`);
|
|
177
|
+
}
|
|
178
|
+
if (entry.ripple && entry.ripple.length > 0) {
|
|
179
|
+
console.log(` Ripple: ${entry.ripple.map((r) => {
|
|
180
|
+
if (r.startsWith("@")) return chalk.blue(r);
|
|
181
|
+
if (r.startsWith("#")) return chalk.green(r);
|
|
182
|
+
if (r.startsWith("^")) return chalk.red(r);
|
|
183
|
+
return chalk.gray(r);
|
|
184
|
+
}).join(", ")}`);
|
|
185
|
+
}
|
|
186
|
+
console.log("");
|
|
187
|
+
if (entry.resolution) {
|
|
188
|
+
console.log(chalk.white("Resolution:"));
|
|
189
|
+
console.log(chalk.gray("\u2500".repeat(50)));
|
|
190
|
+
console.log(chalk.green(` ${entry.resolution}`));
|
|
191
|
+
console.log("");
|
|
192
|
+
}
|
|
193
|
+
console.log(chalk.gray("Tip: Run `paradigm ripple " + (entry.symbol || entry.signal || "") + "` for full impact analysis.\n"));
|
|
194
|
+
}
|
|
195
|
+
async function echoInitCommand(targetPath, options = {}) {
|
|
196
|
+
const cwd = process.cwd();
|
|
197
|
+
const absolutePath = targetPath ? path.resolve(cwd, targetPath) : cwd;
|
|
198
|
+
const paradigmDir = path.join(absolutePath, ".paradigm");
|
|
199
|
+
const echoesPath = path.join(paradigmDir, "echoes.yaml");
|
|
200
|
+
if (!fs.existsSync(paradigmDir)) {
|
|
201
|
+
fs.mkdirSync(paradigmDir, { recursive: true });
|
|
202
|
+
}
|
|
203
|
+
if (fs.existsSync(echoesPath) && !options.quiet) {
|
|
204
|
+
console.log(chalk.yellow("\n\u26A0\uFE0F echoes.yaml already exists.\n"));
|
|
205
|
+
console.log(chalk.gray(` Path: ${echoesPath}
|
|
206
|
+
`));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
fs.writeFileSync(echoesPath, ECHOES_TEMPLATE, "utf8");
|
|
210
|
+
if (!options.quiet) {
|
|
211
|
+
console.log(chalk.green("\n\u2713 Created .paradigm/echoes.yaml\n"));
|
|
212
|
+
console.log(chalk.gray(" Edit this file to add error-to-symbol mappings."));
|
|
213
|
+
console.log(chalk.gray(" Then use `paradigm echo ERROR_CODE` to look them up.\n"));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function echoListCommand(targetPath, _options = {}) {
|
|
217
|
+
const cwd = process.cwd();
|
|
218
|
+
const absolutePath = targetPath ? path.resolve(cwd, targetPath) : cwd;
|
|
219
|
+
const echoesPath = path.join(absolutePath, ".paradigm", "echoes.yaml");
|
|
220
|
+
if (!fs.existsSync(echoesPath)) {
|
|
221
|
+
console.log(chalk.yellow("\n\u{1F4E2} No echoes.yaml found.\n"));
|
|
222
|
+
console.log(chalk.gray(" Run `paradigm echo --init` to create one.\n"));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const content = fs.readFileSync(echoesPath, "utf8");
|
|
226
|
+
const data = parseEchoes(content);
|
|
227
|
+
console.log(chalk.blue("\n\u{1F4E2} All Echoes\n"));
|
|
228
|
+
console.log(chalk.gray("\u2500".repeat(50)));
|
|
229
|
+
const codes = Object.keys(data.errors);
|
|
230
|
+
if (codes.length === 0) {
|
|
231
|
+
console.log(chalk.gray(" No error mappings defined yet.\n"));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
for (const code of codes) {
|
|
235
|
+
const entry = data.errors[code];
|
|
236
|
+
const symbol = entry.symbol || entry.signal || "";
|
|
237
|
+
const location = entry.location ? chalk.gray(` @ ${entry.location}`) : "";
|
|
238
|
+
console.log(` ${chalk.cyan(code.padEnd(20))} \u2192 ${symbol}${location}`);
|
|
239
|
+
}
|
|
240
|
+
console.log(chalk.gray(`
|
|
241
|
+
Total: ${codes.length} error mappings
|
|
242
|
+
`));
|
|
243
|
+
}
|
|
244
|
+
export {
|
|
245
|
+
echoCommand,
|
|
246
|
+
echoInitCommand,
|
|
247
|
+
echoListCommand
|
|
248
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
AuditLogger
|
|
4
|
+
} from "./chunk-PBHIFAL4.js";
|
|
5
|
+
import "./chunk-MO4EEYFW.js";
|
|
6
|
+
|
|
7
|
+
// src/commands/team/export.ts
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import chalk from "chalk";
|
|
10
|
+
async function teamExportCommand(targetPath, options) {
|
|
11
|
+
const rootDir = targetPath ? path.resolve(targetPath) : process.cwd();
|
|
12
|
+
let from;
|
|
13
|
+
let to;
|
|
14
|
+
if (options.from) {
|
|
15
|
+
from = new Date(options.from);
|
|
16
|
+
}
|
|
17
|
+
if (options.to) {
|
|
18
|
+
to = new Date(options.to);
|
|
19
|
+
}
|
|
20
|
+
const auditLogger = new AuditLogger(rootDir);
|
|
21
|
+
const format = options.format || "json";
|
|
22
|
+
let output;
|
|
23
|
+
if (format === "csv") {
|
|
24
|
+
output = auditLogger.exportToCsv({ from, to });
|
|
25
|
+
} else {
|
|
26
|
+
output = auditLogger.exportToJson({ from, to });
|
|
27
|
+
}
|
|
28
|
+
if (options.output) {
|
|
29
|
+
const fs = await import("fs");
|
|
30
|
+
fs.writeFileSync(options.output, output);
|
|
31
|
+
console.log(chalk.green(`\u2713 Exported to ${options.output}`));
|
|
32
|
+
} else {
|
|
33
|
+
console.log(output);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
teamExportCommand
|
|
38
|
+
};
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "./chunk-MO4EEYFW.js";
|
|
3
|
+
|
|
4
|
+
// src/commands/history/index.ts
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import * as yaml from "js-yaml";
|
|
9
|
+
var HISTORY_DIR = ".paradigm/history";
|
|
10
|
+
async function historyShowCommand(symbol, options = {}) {
|
|
11
|
+
const rootDir = process.cwd();
|
|
12
|
+
const historyPath = path.join(rootDir, HISTORY_DIR);
|
|
13
|
+
if (!fs.existsSync(historyPath)) {
|
|
14
|
+
console.log(chalk.yellow("No history directory found."));
|
|
15
|
+
console.log(chalk.gray(`Run \`paradigm history init\` to create .paradigm/history/`));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const index = loadYaml(path.join(historyPath, "index.yaml"));
|
|
19
|
+
const entries = loadLog(path.join(historyPath, "log.jsonl"));
|
|
20
|
+
if (options.json) {
|
|
21
|
+
if (symbol) {
|
|
22
|
+
const symbolData = index?.by_symbol?.[symbol];
|
|
23
|
+
const symbolEntries = entries.filter((e) => e.symbols.includes(symbol));
|
|
24
|
+
console.log(JSON.stringify({ symbol, summary: symbolData, entries: symbolEntries }, null, 2));
|
|
25
|
+
} else {
|
|
26
|
+
console.log(JSON.stringify({ index, entries: entries.slice(-(options.limit || 20)) }, null, 2));
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
console.log(chalk.magenta("\n History\n"));
|
|
31
|
+
if (symbol) {
|
|
32
|
+
const summary = index?.by_symbol?.[symbol];
|
|
33
|
+
const symbolEntries = entries.filter((e) => e.symbols.includes(symbol)).slice(-(options.limit || 10));
|
|
34
|
+
console.log(chalk.cyan(` Symbol: ${symbol}
|
|
35
|
+
`));
|
|
36
|
+
if (summary) {
|
|
37
|
+
const fragilityColor = summary.fragility === "critical" || summary.fragility === "high" ? chalk.red : summary.fragility === "medium" ? chalk.yellow : chalk.green;
|
|
38
|
+
console.log(chalk.white(" Summary:"));
|
|
39
|
+
console.log(chalk.gray(` Total changes: ${summary.total_changes}`));
|
|
40
|
+
console.log(chalk.gray(` Last modified: ${summary.last_modified}`));
|
|
41
|
+
console.log(chalk.gray(` Stability: ${(summary.stability_score * 100).toFixed(0)}%`));
|
|
42
|
+
console.log(fragilityColor(` Fragility: ${summary.fragility}`));
|
|
43
|
+
console.log();
|
|
44
|
+
}
|
|
45
|
+
if (symbolEntries.length > 0) {
|
|
46
|
+
console.log(chalk.white(" Recent changes:"));
|
|
47
|
+
symbolEntries.forEach((e) => {
|
|
48
|
+
const typeColor = e.type === "rollback" ? chalk.red : e.type === "validate" ? e.result === "pass" ? chalk.green : chalk.red : chalk.blue;
|
|
49
|
+
console.log(
|
|
50
|
+
typeColor(` [${e.type}] ${e.description || e.id}`) + chalk.gray(` - ${e.author.id} @ ${e.ts.split("T")[0]}`)
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const symbols = Object.keys(index?.by_symbol || {});
|
|
57
|
+
console.log(chalk.white(` Tracked symbols: ${symbols.length}`));
|
|
58
|
+
console.log(chalk.white(` Total entries: ${entries.length}`));
|
|
59
|
+
console.log();
|
|
60
|
+
const fragile = index?.fragile_symbols || [];
|
|
61
|
+
if (fragile.length > 0) {
|
|
62
|
+
console.log(chalk.red(" Fragile symbols:"));
|
|
63
|
+
fragile.slice(0, 5).forEach((f) => {
|
|
64
|
+
console.log(chalk.gray(` [${f.fragility}] ${f.symbol}`));
|
|
65
|
+
});
|
|
66
|
+
console.log();
|
|
67
|
+
}
|
|
68
|
+
const recent = entries.slice(-10);
|
|
69
|
+
if (recent.length > 0) {
|
|
70
|
+
console.log(chalk.white(" Recent entries:"));
|
|
71
|
+
recent.reverse().forEach((e) => {
|
|
72
|
+
const typeColor = e.type === "rollback" ? chalk.red : e.type === "validate" ? e.result === "pass" ? chalk.green : chalk.red : chalk.blue;
|
|
73
|
+
console.log(
|
|
74
|
+
typeColor(` [${e.type}] ${e.symbols.join(", ")}`) + chalk.gray(` - ${e.ts.split("T")[0]}`)
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function historyInitCommand(options = {}) {
|
|
80
|
+
const rootDir = process.cwd();
|
|
81
|
+
const historyPath = path.join(rootDir, HISTORY_DIR);
|
|
82
|
+
if (fs.existsSync(historyPath) && !options.force) {
|
|
83
|
+
console.log(chalk.yellow("History directory already exists."));
|
|
84
|
+
console.log(chalk.gray("Use --force to reinitialize"));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
fs.mkdirSync(historyPath, { recursive: true });
|
|
88
|
+
fs.writeFileSync(path.join(historyPath, "log.jsonl"), "");
|
|
89
|
+
const index = {
|
|
90
|
+
version: "1.0",
|
|
91
|
+
generated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
92
|
+
by_symbol: {},
|
|
93
|
+
co_changes: [],
|
|
94
|
+
fragile_symbols: []
|
|
95
|
+
};
|
|
96
|
+
fs.writeFileSync(path.join(historyPath, "index.yaml"), yaml.dump(index, { lineWidth: -1 }));
|
|
97
|
+
const validation = {
|
|
98
|
+
version: "1.0",
|
|
99
|
+
total_validations: 0,
|
|
100
|
+
pass_rate: 0,
|
|
101
|
+
by_symbol: {}
|
|
102
|
+
};
|
|
103
|
+
fs.writeFileSync(path.join(historyPath, "validation.yaml"), yaml.dump(validation, { lineWidth: -1 }));
|
|
104
|
+
console.log(chalk.green("History directory initialized!"));
|
|
105
|
+
console.log(chalk.gray(` ${historyPath}/`));
|
|
106
|
+
console.log(chalk.gray(" log.jsonl"));
|
|
107
|
+
console.log(chalk.gray(" index.yaml"));
|
|
108
|
+
console.log(chalk.gray(" validation.yaml"));
|
|
109
|
+
}
|
|
110
|
+
async function historyFragileCommand(options = {}) {
|
|
111
|
+
const rootDir = process.cwd();
|
|
112
|
+
const indexPath = path.join(rootDir, HISTORY_DIR, "index.yaml");
|
|
113
|
+
if (!fs.existsSync(indexPath)) {
|
|
114
|
+
console.log(chalk.yellow("No history index found."));
|
|
115
|
+
console.log(chalk.gray("Run `paradigm history reindex` to generate"));
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const index = loadYaml(indexPath);
|
|
119
|
+
const fragile = index?.fragile_symbols || [];
|
|
120
|
+
if (options.json) {
|
|
121
|
+
console.log(JSON.stringify({ fragile }, null, 2));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
console.log(chalk.magenta("\n Fragile Symbols\n"));
|
|
125
|
+
if (fragile.length === 0) {
|
|
126
|
+
console.log(chalk.green(" No fragile symbols detected!"));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
fragile.forEach((f) => {
|
|
130
|
+
const color = f.fragility === "critical" ? chalk.red : chalk.yellow;
|
|
131
|
+
console.log(color(` [${f.fragility}] ${f.symbol}`));
|
|
132
|
+
console.log(chalk.gray(` ${f.reason}`));
|
|
133
|
+
});
|
|
134
|
+
console.log();
|
|
135
|
+
console.log(chalk.gray(" Recommendation: Add extra test coverage before modifying these symbols"));
|
|
136
|
+
}
|
|
137
|
+
async function historyReindexCommand() {
|
|
138
|
+
const rootDir = process.cwd();
|
|
139
|
+
const historyPath = path.join(rootDir, HISTORY_DIR);
|
|
140
|
+
const logPath = path.join(historyPath, "log.jsonl");
|
|
141
|
+
if (!fs.existsSync(logPath)) {
|
|
142
|
+
console.log(chalk.yellow("No history log found."));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const entries = loadLog(logPath);
|
|
146
|
+
const index = buildIndex(entries);
|
|
147
|
+
const indexPath = path.join(historyPath, "index.yaml");
|
|
148
|
+
fs.writeFileSync(indexPath, yaml.dump(index, { lineWidth: -1 }));
|
|
149
|
+
console.log(chalk.green("History index regenerated!"));
|
|
150
|
+
console.log(chalk.gray(` Symbols: ${Object.keys(index.by_symbol).length}`));
|
|
151
|
+
console.log(chalk.gray(` Entries: ${entries.length}`));
|
|
152
|
+
console.log(chalk.gray(` Fragile: ${index.fragile_symbols.length}`));
|
|
153
|
+
}
|
|
154
|
+
async function historyRecordCommand(options) {
|
|
155
|
+
const rootDir = process.cwd();
|
|
156
|
+
const logPath = path.join(rootDir, HISTORY_DIR, "log.jsonl");
|
|
157
|
+
fs.mkdirSync(path.join(rootDir, HISTORY_DIR), { recursive: true });
|
|
158
|
+
let count = 1;
|
|
159
|
+
if (fs.existsSync(logPath)) {
|
|
160
|
+
const content = fs.readFileSync(logPath, "utf8");
|
|
161
|
+
count = content.split("\n").filter((l) => l.trim()).length + 1;
|
|
162
|
+
}
|
|
163
|
+
const entry = {
|
|
164
|
+
id: `h${String(count).padStart(4, "0")}`,
|
|
165
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
166
|
+
type: options.type,
|
|
167
|
+
symbols: options.symbols.split(",").map((s) => s.trim()),
|
|
168
|
+
author: { type: "human", id: process.env.USER || "unknown" },
|
|
169
|
+
description: options.description,
|
|
170
|
+
intent: options.intent,
|
|
171
|
+
commit: options.commit,
|
|
172
|
+
reason: options.reason
|
|
173
|
+
};
|
|
174
|
+
fs.appendFileSync(logPath, JSON.stringify(entry) + "\n");
|
|
175
|
+
console.log(chalk.green(`Entry ${entry.id} recorded!`));
|
|
176
|
+
}
|
|
177
|
+
async function historyValidateCommand(options) {
|
|
178
|
+
const rootDir = process.cwd();
|
|
179
|
+
const logPath = path.join(rootDir, HISTORY_DIR, "log.jsonl");
|
|
180
|
+
fs.mkdirSync(path.join(rootDir, HISTORY_DIR), { recursive: true });
|
|
181
|
+
let count = 1;
|
|
182
|
+
if (fs.existsSync(logPath)) {
|
|
183
|
+
const content = fs.readFileSync(logPath, "utf8");
|
|
184
|
+
count = content.split("\n").filter((l) => l.trim()).length + 1;
|
|
185
|
+
}
|
|
186
|
+
const entry = {
|
|
187
|
+
id: `h${String(count).padStart(4, "0")}`,
|
|
188
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
189
|
+
type: "validate",
|
|
190
|
+
symbols: [],
|
|
191
|
+
author: { type: "agent", id: "cli" },
|
|
192
|
+
ref: options.ref,
|
|
193
|
+
result: options.result,
|
|
194
|
+
tests: options.passed !== void 0 ? { passed: options.passed, failed: options.failed || 0 } : void 0
|
|
195
|
+
};
|
|
196
|
+
fs.appendFileSync(logPath, JSON.stringify(entry) + "\n");
|
|
197
|
+
console.log(chalk.green(`Validation ${entry.id} recorded: ${options.result}`));
|
|
198
|
+
}
|
|
199
|
+
function loadYaml(filePath) {
|
|
200
|
+
if (!fs.existsSync(filePath)) return null;
|
|
201
|
+
try {
|
|
202
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
203
|
+
return yaml.load(content);
|
|
204
|
+
} catch {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function loadLog(logPath) {
|
|
209
|
+
if (!fs.existsSync(logPath)) return [];
|
|
210
|
+
const content = fs.readFileSync(logPath, "utf8");
|
|
211
|
+
return content.split("\n").filter((l) => l.trim()).map((l) => {
|
|
212
|
+
try {
|
|
213
|
+
return JSON.parse(l);
|
|
214
|
+
} catch {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}).filter(Boolean);
|
|
218
|
+
}
|
|
219
|
+
function buildIndex(entries) {
|
|
220
|
+
const bySymbol = {};
|
|
221
|
+
const symbolChanges = {};
|
|
222
|
+
for (const entry of entries) {
|
|
223
|
+
for (const symbol of entry.symbols) {
|
|
224
|
+
if (!symbolChanges[symbol]) symbolChanges[symbol] = [];
|
|
225
|
+
symbolChanges[symbol].push(entry);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (const [symbol, changes] of Object.entries(symbolChanges)) {
|
|
229
|
+
const sorted = changes.sort((a, b) => new Date(b.ts).getTime() - new Date(a.ts).getTime());
|
|
230
|
+
const rollbacks = changes.filter((c) => c.type === "rollback").length;
|
|
231
|
+
const failures = changes.filter((c) => c.type === "validate" && c.result === "fail").length;
|
|
232
|
+
const total = changes.length;
|
|
233
|
+
const stabilityScore = Math.max(0, 1 - (rollbacks * 0.2 + failures * 0.1) / Math.max(1, total / 10));
|
|
234
|
+
let fragility = "low";
|
|
235
|
+
if (stabilityScore < 0.5) fragility = "critical";
|
|
236
|
+
else if (stabilityScore < 0.7) fragility = "high";
|
|
237
|
+
else if (stabilityScore < 0.85) fragility = "medium";
|
|
238
|
+
const humanContributors = /* @__PURE__ */ new Set();
|
|
239
|
+
const agentContributors = /* @__PURE__ */ new Set();
|
|
240
|
+
for (const change of changes) {
|
|
241
|
+
if (change.author.type === "human") humanContributors.add(change.author.id);
|
|
242
|
+
else agentContributors.add(change.author.id);
|
|
243
|
+
}
|
|
244
|
+
bySymbol[symbol] = {
|
|
245
|
+
symbol,
|
|
246
|
+
total_changes: total,
|
|
247
|
+
last_modified: sorted[0]?.ts || (/* @__PURE__ */ new Date()).toISOString(),
|
|
248
|
+
stability_score: stabilityScore,
|
|
249
|
+
fragility,
|
|
250
|
+
recent: sorted.slice(0, 5),
|
|
251
|
+
contributors: {
|
|
252
|
+
human: Array.from(humanContributors),
|
|
253
|
+
agent: Array.from(agentContributors)
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const fragileSymbols = Object.values(bySymbol).filter((s) => s.fragility === "high" || s.fragility === "critical").map((s) => ({
|
|
258
|
+
symbol: s.symbol,
|
|
259
|
+
fragility: s.fragility,
|
|
260
|
+
reason: `Stability score: ${(s.stability_score * 100).toFixed(0)}%`
|
|
261
|
+
}));
|
|
262
|
+
return {
|
|
263
|
+
version: "1.0",
|
|
264
|
+
generated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
265
|
+
by_symbol: bySymbol,
|
|
266
|
+
co_changes: [],
|
|
267
|
+
fragile_symbols: fragileSymbols
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
historyFragileCommand,
|
|
272
|
+
historyInitCommand,
|
|
273
|
+
historyRecordCommand,
|
|
274
|
+
historyReindexCommand,
|
|
275
|
+
historyShowCommand,
|
|
276
|
+
historyValidateCommand
|
|
277
|
+
};
|
package/dist/index.d.ts
ADDED