@ariacode/cli 0.1.0 → 0.2.1
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 +175 -4
- package/dist/actions/db-ask.d.ts +12 -0
- package/dist/actions/db-ask.js +130 -0
- package/dist/actions/db-ask.js.map +1 -0
- package/dist/actions/db-explain.d.ts +12 -0
- package/dist/actions/db-explain.js +123 -0
- package/dist/actions/db-explain.js.map +1 -0
- package/dist/actions/db-migrate.d.ts +13 -0
- package/dist/actions/db-migrate.js +124 -0
- package/dist/actions/db-migrate.js.map +1 -0
- package/dist/actions/db-schema.d.ts +11 -0
- package/dist/actions/db-schema.js +38 -0
- package/dist/actions/db-schema.js.map +1 -0
- package/dist/actions/upgrade-deps.d.ts +14 -0
- package/dist/actions/upgrade-deps.js +227 -0
- package/dist/actions/upgrade-deps.js.map +1 -0
- package/dist/actions/upgrade-prisma.d.ts +12 -0
- package/dist/actions/upgrade-prisma.js +177 -0
- package/dist/actions/upgrade-prisma.js.map +1 -0
- package/dist/actions.js +48 -13
- package/dist/actions.js.map +1 -1
- package/dist/agent.js +28 -9
- package/dist/agent.js.map +1 -1
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -1
- package/dist/db/client-usage.d.ts +19 -0
- package/dist/db/client-usage.js +107 -0
- package/dist/db/client-usage.js.map +1 -0
- package/dist/db/migrate.d.ts +26 -0
- package/dist/db/migrate.js +59 -0
- package/dist/db/migrate.js.map +1 -0
- package/dist/db/schema.d.ts +106 -0
- package/dist/db/schema.js +275 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/summary.d.ts +12 -0
- package/dist/db/summary.js +133 -0
- package/dist/db/summary.js.map +1 -0
- package/dist/fs-helpers.d.ts +19 -0
- package/dist/fs-helpers.js +92 -0
- package/dist/fs-helpers.js.map +1 -0
- package/dist/parser.d.ts +9 -0
- package/dist/parser.js +86 -0
- package/dist/parser.js.map +1 -1
- package/dist/prompt-loader.d.ts +9 -0
- package/dist/prompt-loader.js +26 -0
- package/dist/prompt-loader.js.map +1 -0
- package/dist/prompts/db_ask.md +39 -0
- package/dist/prompts/db_explain.md +43 -0
- package/dist/prompts/db_migrate.md +48 -0
- package/dist/prompts/upgrade_deps.md +23 -0
- package/dist/prompts/upgrade_prisma.md +28 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +6 -35
- package/dist/provider.js.map +1 -1
- package/dist/storage.d.ts +11 -0
- package/dist/storage.js +36 -4
- package/dist/storage.js.map +1 -1
- package/dist/tools.d.ts +26 -0
- package/dist/tools.js +256 -8
- package/dist/tools.js.map +1 -1
- package/dist/upgrade/changelog.d.ts +21 -0
- package/dist/upgrade/changelog.js +62 -0
- package/dist/upgrade/changelog.js.map +1 -0
- package/dist/upgrade/classifier.d.ts +25 -0
- package/dist/upgrade/classifier.js +78 -0
- package/dist/upgrade/classifier.js.map +1 -0
- package/dist/upgrade/outdated.d.ts +17 -0
- package/dist/upgrade/outdated.js +138 -0
- package/dist/upgrade/outdated.js.map +1 -0
- package/dist/upgrade/prisma-upgrade.d.ts +20 -0
- package/dist/upgrade/prisma-upgrade.js +63 -0
- package/dist/upgrade/prisma-upgrade.js.map +1 -0
- package/package.json +7 -4
- package/dist/prompts/prompts/ask.md +0 -20
- package/dist/prompts/prompts/explore.md +0 -38
- package/dist/prompts/prompts/patch.md +0 -27
- package/dist/prompts/prompts/plan.md +0 -41
- package/dist/prompts/prompts/review.md +0 -33
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared filesystem helpers — atomic writes, safe JSON parsing.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Atomically write a file by writing to a temp file first, then renaming.
|
|
6
|
+
* - Uses fsync to ensure data is flushed to disk before rename.
|
|
7
|
+
* - Preserves original file permissions (important for 0600 config files).
|
|
8
|
+
* - Temp file is named with the target basename for easy orphan attribution.
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeFileAtomic(filePath: string, content: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Safely read and parse a JSON file. Throws a descriptive error on failure.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readJsonFile(filePath: string): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Detect the user's shell rc file based on $SHELL.
|
|
17
|
+
* macOS bash uses .bash_profile (not .bashrc). Linux bash uses .bashrc.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getShellRcPath(): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared filesystem helpers — atomic writes, safe JSON parsing.
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import * as os from 'node:os';
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
/**
|
|
9
|
+
* Atomically write a file by writing to a temp file first, then renaming.
|
|
10
|
+
* - Uses fsync to ensure data is flushed to disk before rename.
|
|
11
|
+
* - Preserves original file permissions (important for 0600 config files).
|
|
12
|
+
* - Temp file is named with the target basename for easy orphan attribution.
|
|
13
|
+
*/
|
|
14
|
+
export function writeFileAtomic(filePath, content) {
|
|
15
|
+
const dir = path.dirname(filePath);
|
|
16
|
+
const base = path.basename(filePath);
|
|
17
|
+
const tmpPath = path.join(dir, `.${base}.tmp-${randomUUID().slice(0, 8)}`);
|
|
18
|
+
// Capture original permissions before writing (if file exists).
|
|
19
|
+
// Mask off file-type bits (S_IFMT) — we only want the permission bits.
|
|
20
|
+
let originalMode = null;
|
|
21
|
+
try {
|
|
22
|
+
originalMode = fs.statSync(filePath).mode & 0o7777;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// File doesn't exist yet — no permissions to preserve
|
|
26
|
+
}
|
|
27
|
+
// For new files, default to 0o644. Callers that need stricter permissions
|
|
28
|
+
// (e.g. 0o600 for config.toml) should chmod after writeFileAtomic returns,
|
|
29
|
+
// or the file should already exist with the desired mode.
|
|
30
|
+
const mode = originalMode ?? 0o644;
|
|
31
|
+
try {
|
|
32
|
+
// Write to temp file
|
|
33
|
+
const fd = fs.openSync(tmpPath, 'w', mode);
|
|
34
|
+
try {
|
|
35
|
+
fs.writeSync(fd, content);
|
|
36
|
+
fs.fsyncSync(fd);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
fs.closeSync(fd);
|
|
40
|
+
}
|
|
41
|
+
// Ensure permissions match regardless of umask
|
|
42
|
+
fs.chmodSync(tmpPath, mode);
|
|
43
|
+
// Atomic rename
|
|
44
|
+
fs.renameSync(tmpPath, filePath);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
// Clean up temp file on failure
|
|
48
|
+
try {
|
|
49
|
+
fs.unlinkSync(tmpPath);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// ignore cleanup errors
|
|
53
|
+
}
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Safely read and parse a JSON file. Throws a descriptive error on failure.
|
|
59
|
+
*/
|
|
60
|
+
export function readJsonFile(filePath) {
|
|
61
|
+
let raw;
|
|
62
|
+
try {
|
|
63
|
+
raw = fs.readFileSync(filePath, 'utf-8');
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
throw new Error(`Cannot read ${path.basename(filePath)}: ${err instanceof Error ? err.message : String(err)}`);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(raw);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
throw new Error(`Invalid JSON in ${path.basename(filePath)}: ${err instanceof Error ? err.message : String(err)}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Detect the user's shell rc file based on $SHELL.
|
|
77
|
+
* macOS bash uses .bash_profile (not .bashrc). Linux bash uses .bashrc.
|
|
78
|
+
*/
|
|
79
|
+
export function getShellRcPath() {
|
|
80
|
+
const shell = process.env['SHELL'] ?? '';
|
|
81
|
+
if (shell.endsWith('/zsh'))
|
|
82
|
+
return path.join(os.homedir(), '.zshrc');
|
|
83
|
+
if (shell.endsWith('/bash')) {
|
|
84
|
+
// macOS bash sources .bash_profile, not .bashrc
|
|
85
|
+
return path.join(os.homedir(), process.platform === 'darwin' ? '.bash_profile' : '.bashrc');
|
|
86
|
+
}
|
|
87
|
+
if (shell.endsWith('/fish'))
|
|
88
|
+
return path.join(os.homedir(), '.config', 'fish', 'config.fish');
|
|
89
|
+
// Default: zsh on macOS, bash on Linux
|
|
90
|
+
return path.join(os.homedir(), process.platform === 'darwin' ? '.zshrc' : '.bashrc');
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=fs-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-helpers.js","sourceRoot":"","sources":["../src/fs-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,OAAe;IAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,QAAQ,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAE3E,gEAAgE;IAChE,uEAAuE;IACvE,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,CAAC;QACH,YAAY,GAAG,EAAE,CAA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AC,CAAC,SAAS,CAAC,CAAC;AACvF,CAAC"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -23,6 +23,15 @@ export interface ParsedArgs {
|
|
|
23
23
|
configSubcommand?: "get" | "set" | "path" | "init";
|
|
24
24
|
configKey?: string;
|
|
25
25
|
configValue?: string;
|
|
26
|
+
dbSubcommand?: "schema" | "ask" | "explain" | "migrate";
|
|
27
|
+
dbQuestion?: string;
|
|
28
|
+
dbDescription?: string;
|
|
29
|
+
dbModel?: string;
|
|
30
|
+
dbFile?: string;
|
|
31
|
+
dbJson?: boolean;
|
|
32
|
+
upgradeSubcommand?: "deps" | "prisma";
|
|
33
|
+
upgradeRisk?: "patch" | "minor" | "major" | "all";
|
|
34
|
+
upgradeDev?: boolean;
|
|
26
35
|
}
|
|
27
36
|
export declare const GLOBAL_USAGE: string;
|
|
28
37
|
export declare const COMMAND_USAGE: Record<string, string>;
|
package/dist/parser.js
CHANGED
|
@@ -21,6 +21,8 @@ ${pc.bold("COMMANDS:")}
|
|
|
21
21
|
history View session history
|
|
22
22
|
config Manage configuration
|
|
23
23
|
doctor Check environment and project detection
|
|
24
|
+
db Prisma database assistant (schema, ask, explain, migrate)
|
|
25
|
+
upgrade Upgrade dependencies and frameworks (deps, prisma)
|
|
24
26
|
|
|
25
27
|
${pc.bold("GLOBAL OPTIONS:")}
|
|
26
28
|
--dry-run Preview changes without applying them
|
|
@@ -113,6 +115,41 @@ ${pc.bold("USAGE:")}
|
|
|
113
115
|
|
|
114
116
|
${pc.bold("OPTIONS:")}
|
|
115
117
|
--format <text|json> Output format (default: text)
|
|
118
|
+
`,
|
|
119
|
+
db: `
|
|
120
|
+
${pc.bold("USAGE:")}
|
|
121
|
+
aria db <subcommand> [options]
|
|
122
|
+
|
|
123
|
+
${pc.bold("SUBCOMMANDS:")}
|
|
124
|
+
schema Parse and render schema.prisma (no LLM)
|
|
125
|
+
ask <question> Q&A over Prisma schema, generates Prisma Client code
|
|
126
|
+
explain <description> Analyze Prisma Client usage and explain performance
|
|
127
|
+
migrate <description> Propose changes to schema.prisma (never runs migrations)
|
|
128
|
+
|
|
129
|
+
${pc.bold("OPTIONS:")}
|
|
130
|
+
--model <name> Filter to a specific Prisma model
|
|
131
|
+
--file <path> Focus on a specific file (db explain)
|
|
132
|
+
--json Output as JSON (db schema)
|
|
133
|
+
--dry-run Preview without applying (db migrate)
|
|
134
|
+
--yes Skip confirmation (db migrate)
|
|
135
|
+
`,
|
|
136
|
+
upgrade: `
|
|
137
|
+
${pc.bold("USAGE:")}
|
|
138
|
+
aria upgrade <subcommand> [options]
|
|
139
|
+
|
|
140
|
+
${pc.bold("SUBCOMMANDS:")}
|
|
141
|
+
deps Analyze and upgrade outdated dependencies
|
|
142
|
+
prisma Prisma-specific upgrade with migration guidance
|
|
143
|
+
|
|
144
|
+
${pc.bold("OPTIONS (deps):")}
|
|
145
|
+
--risk <level> Filter by risk: patch, minor, major, all (default: minor)
|
|
146
|
+
--dev Include devDependencies in upgrade
|
|
147
|
+
--dry-run Preview without modifying package.json
|
|
148
|
+
--yes Skip confirmation prompt
|
|
149
|
+
|
|
150
|
+
${pc.bold("OPTIONS (prisma):")}
|
|
151
|
+
--dry-run Preview without modifying package.json
|
|
152
|
+
--yes Skip confirmation prompt
|
|
116
153
|
`,
|
|
117
154
|
};
|
|
118
155
|
// ---------------------------------------------------------------------------
|
|
@@ -202,6 +239,33 @@ export function parseCLI(argv = process.argv.slice(2)) {
|
|
|
202
239
|
else if (token === "--tree") {
|
|
203
240
|
args.tree = true;
|
|
204
241
|
}
|
|
242
|
+
else if (token === "--json") {
|
|
243
|
+
args.dbJson = true;
|
|
244
|
+
}
|
|
245
|
+
else if (token === "--model") {
|
|
246
|
+
i++;
|
|
247
|
+
args.dbModel = tokens[i];
|
|
248
|
+
}
|
|
249
|
+
else if (token.startsWith("--model=")) {
|
|
250
|
+
args.dbModel = token.slice("--model=".length);
|
|
251
|
+
}
|
|
252
|
+
else if (token === "--file") {
|
|
253
|
+
i++;
|
|
254
|
+
args.dbFile = tokens[i];
|
|
255
|
+
}
|
|
256
|
+
else if (token.startsWith("--file=")) {
|
|
257
|
+
args.dbFile = token.slice("--file=".length);
|
|
258
|
+
}
|
|
259
|
+
else if (token === "--risk") {
|
|
260
|
+
i++;
|
|
261
|
+
args.upgradeRisk = tokens[i];
|
|
262
|
+
}
|
|
263
|
+
else if (token.startsWith("--risk=")) {
|
|
264
|
+
args.upgradeRisk = token.slice("--risk=".length);
|
|
265
|
+
}
|
|
266
|
+
else if (token === "--dev") {
|
|
267
|
+
args.upgradeDev = true;
|
|
268
|
+
}
|
|
205
269
|
else if (token === "--help" || token === "-h") {
|
|
206
270
|
positionals.unshift("--help");
|
|
207
271
|
}
|
|
@@ -248,6 +312,26 @@ export function parseCLI(argv = process.argv.slice(2)) {
|
|
|
248
312
|
}
|
|
249
313
|
break;
|
|
250
314
|
}
|
|
315
|
+
case "db": {
|
|
316
|
+
const sub = positionals[1];
|
|
317
|
+
if (sub === "schema" || sub === "ask" || sub === "explain" || sub === "migrate") {
|
|
318
|
+
args.dbSubcommand = sub;
|
|
319
|
+
if (sub === "ask" && positionals[2]) {
|
|
320
|
+
args.dbQuestion = positionals[2];
|
|
321
|
+
}
|
|
322
|
+
else if ((sub === "explain" || sub === "migrate") && positionals[2]) {
|
|
323
|
+
args.dbDescription = positionals[2];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "upgrade": {
|
|
329
|
+
const sub = positionals[1];
|
|
330
|
+
if (sub === "deps" || sub === "prisma") {
|
|
331
|
+
args.upgradeSubcommand = sub;
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
251
335
|
}
|
|
252
336
|
return args;
|
|
253
337
|
}
|
|
@@ -309,6 +393,8 @@ export function validateArgs(args) {
|
|
|
309
393
|
case "explore":
|
|
310
394
|
case "history":
|
|
311
395
|
case "doctor":
|
|
396
|
+
case "db":
|
|
397
|
+
case "upgrade":
|
|
312
398
|
case null:
|
|
313
399
|
case "--help":
|
|
314
400
|
case "--version":
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AA4C5B,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,YAAY,GAAG;EAC1B,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;;EAEf,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;;;EAGjB,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;;;;;;;;;;;EAYpB,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC;;;;;;;;CAQ3B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,GAAG,EAAE;EACL,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;;;EAGjB,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;;;EAGrB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;;;;CAIpB;IACC,IAAI,EAAE;EACN,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;;;EAGjB,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;;;EAGrB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;;;CAGpB;IACC,KAAK,EAAE;EACP,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;;;EAGjB,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;;;EAGrB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC;;;;CAIpB;IACC,MAAM,EAAE;EACR,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;;;EAGjB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,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACvD,IAAI,CAAC,sCAAsC,EAAE,QAAQ,CAAC,CAAC;YACzD,CAAC;YACD,IACE,IAAI,CAAC,gBAAgB,KAAK,KAAK;gBAC/B,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,EACnD,CAAC;gBACD,IAAI,CAAC,iDAAiD,EAAE,QAAQ,CAAC,CAAC;YACpE,CAAC;YACD,MAAM;QACR,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI,CAAC;QACV,KAAK,SAAS,CAAC;QACf,KAAK,IAAI,CAAC;QACV,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW;YACd,MAAM;QACR;YACE,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAClD,IAAI,CACF,qBAAqB,IAAI,CAAC,OAAO,8CAA8C,CAChF,CAAC;YACJ,CAAC;YACD,MAAM;IACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prompt template loader.
|
|
3
|
+
* Eliminates duplicated __dirname + readFileSync + fallback logic across 6+ action files.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Load a prompt template from src/prompts/{name}.md.
|
|
7
|
+
* Returns the fallback string if the file cannot be read.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadPromptTemplate(name: string, fallback: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared prompt template loader.
|
|
3
|
+
* Eliminates duplicated __dirname + readFileSync + fallback logic across 6+ action files.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { join, dirname } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
/**
|
|
10
|
+
* Load a prompt template from src/prompts/{name}.md.
|
|
11
|
+
* Returns the fallback string if the file cannot be read.
|
|
12
|
+
*/
|
|
13
|
+
export function loadPromptTemplate(name, fallback) {
|
|
14
|
+
// Guard against path traversal — name must be a simple identifier
|
|
15
|
+
if (name.includes('/') || name.includes('\\') || name.includes('..') || name.includes('\0')) {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
const templatePath = join(__dirname, 'prompts', `${name}.md`);
|
|
19
|
+
try {
|
|
20
|
+
return readFileSync(templatePath, 'utf-8');
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=prompt-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-loader.js","sourceRoot":"","sources":["../src/prompt-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,QAAgB;IAC/D,kEAAkE;IAClE,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5F,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,KAAK,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
You are Aria Code's Prisma DB Assistant. You answer questions about Prisma schemas and generate Prisma Client code.
|
|
2
|
+
|
|
3
|
+
## Project context
|
|
4
|
+
|
|
5
|
+
- Project type: {{projectType}}
|
|
6
|
+
- Prisma schema path: {{schemaPath}}
|
|
7
|
+
- Datasource provider: {{datasourceProvider}}
|
|
8
|
+
|
|
9
|
+
## Schema overview
|
|
10
|
+
|
|
11
|
+
{{schemaSummary}}
|
|
12
|
+
|
|
13
|
+
## Your job
|
|
14
|
+
|
|
15
|
+
Answer the user's question by:
|
|
16
|
+
1. Reading the full parsed schema if you need details beyond the summary
|
|
17
|
+
2. Searching for existing Prisma Client usage in the code if relevant
|
|
18
|
+
3. Writing idiomatic Prisma Client code as the answer
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- ALWAYS generate runnable Prisma Client code, not pseudocode
|
|
23
|
+
- ALWAYS use TypeScript
|
|
24
|
+
- ALWAYS use type-safe where clauses (use model fields that exist in schema)
|
|
25
|
+
- NEVER invent fields that don't exist in the schema — verify via the tool
|
|
26
|
+
- NEVER write raw SQL unless the user explicitly asks for $queryRaw
|
|
27
|
+
- NEVER execute queries — Aria has no database access
|
|
28
|
+
- If the question touches sensitive fields (password, token, secret, apiKey, hash, ssn, stripeCustomerId),
|
|
29
|
+
add a prominent WARNING above the code block
|
|
30
|
+
- If there's a performance concern, mention it briefly after the code
|
|
31
|
+
- Keep explanations concise. The code is the primary answer.
|
|
32
|
+
|
|
33
|
+
## Output format
|
|
34
|
+
|
|
35
|
+
Start with a 1-2 sentence explanation of your approach.
|
|
36
|
+
Then provide the Prisma Client code in a TypeScript code block.
|
|
37
|
+
End with a brief note if there are caveats (performance, limitations, alternatives).
|
|
38
|
+
|
|
39
|
+
Do not include installation instructions or imports — the user has Prisma set up.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
You are Aria Code's Prisma query analyzer. You explain how Prisma Client code works and identify performance issues.
|
|
2
|
+
|
|
3
|
+
## Project context
|
|
4
|
+
|
|
5
|
+
- Project type: {{projectType}}
|
|
6
|
+
- Prisma schema: {{schemaPath}}
|
|
7
|
+
- Datasource provider: {{datasourceProvider}}
|
|
8
|
+
|
|
9
|
+
## Schema summary
|
|
10
|
+
|
|
11
|
+
{{schemaSummary}}
|
|
12
|
+
|
|
13
|
+
## Your job
|
|
14
|
+
|
|
15
|
+
Analyze Prisma Client usage in the codebase and explain:
|
|
16
|
+
1. What the query actually does at the database level
|
|
17
|
+
2. Performance characteristics (how many queries, how much data)
|
|
18
|
+
3. Risks: N+1 queries, over-fetching, missing indexes, cartesian products
|
|
19
|
+
4. Concrete improvements
|
|
20
|
+
|
|
21
|
+
## Tools available
|
|
22
|
+
|
|
23
|
+
- read_prisma_schema_parsed — get full schema details
|
|
24
|
+
- find_prisma_usage — find Prisma Client calls in code
|
|
25
|
+
- find_model_references — find all references to a model
|
|
26
|
+
- read_file — read specific files
|
|
27
|
+
- search_code — search for patterns
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
|
|
31
|
+
- Always read the actual code before analyzing — don't guess
|
|
32
|
+
- Identify specific files and line numbers when pointing to issues
|
|
33
|
+
- When suggesting indexes, show the exact `@@index` line to add to schema
|
|
34
|
+
- When suggesting query changes, show before/after code blocks
|
|
35
|
+
- Prioritize by impact: N+1 queries > missing indexes > over-fetching > style
|
|
36
|
+
- Be honest: if the query looks fine, say so briefly
|
|
37
|
+
|
|
38
|
+
## Output format
|
|
39
|
+
|
|
40
|
+
1. Brief description of what the query does
|
|
41
|
+
2. Performance analysis (bullet points with ✓ and ✗)
|
|
42
|
+
3. Suggested improvements (numbered list with code blocks)
|
|
43
|
+
4. Schema additions if applicable (indexes, etc.)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
You are Aria Code's schema migration assistant. You propose changes to Prisma schemas.
|
|
2
|
+
|
|
3
|
+
## Project context
|
|
4
|
+
|
|
5
|
+
- Project type: {{projectType}}
|
|
6
|
+
- Prisma schema path: {{schemaPath}}
|
|
7
|
+
- Datasource provider: {{datasourceProvider}}
|
|
8
|
+
|
|
9
|
+
## Current schema
|
|
10
|
+
|
|
11
|
+
{{schemaContent}}
|
|
12
|
+
|
|
13
|
+
## Your job
|
|
14
|
+
|
|
15
|
+
Propose minimal, focused changes to schema.prisma to accomplish the user's request.
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
- Make the SMALLEST change that satisfies the request
|
|
20
|
+
- Preserve existing formatting, comments, and documentation
|
|
21
|
+
- Add documentation comments (///) for new fields explaining their purpose
|
|
22
|
+
- Consider adding indexes for new fields that will be queried
|
|
23
|
+
- Use appropriate Prisma types based on the datasource provider
|
|
24
|
+
- Add @default values where sensible (e.g., timestamps, booleans)
|
|
25
|
+
- Never remove fields unless explicitly asked
|
|
26
|
+
- Never rename models unless explicitly asked
|
|
27
|
+
- Never change datasource or generator blocks unless explicitly asked
|
|
28
|
+
|
|
29
|
+
## Migration safety
|
|
30
|
+
|
|
31
|
+
After your proposed change, assess:
|
|
32
|
+
- Does this add a required field to an existing table? → Warn about need for default or migration step
|
|
33
|
+
- Does this change a field type? → Warn about data migration implications
|
|
34
|
+
- Does this add a unique constraint? → Warn about potential data conflicts
|
|
35
|
+
- Does this drop anything? → Warn loudly
|
|
36
|
+
|
|
37
|
+
## Output format
|
|
38
|
+
|
|
39
|
+
1. Brief explanation of the change (1-2 sentences)
|
|
40
|
+
2. Use the `propose_schema_change` tool with the full new schema content
|
|
41
|
+
3. List migration safety notes if any
|
|
42
|
+
|
|
43
|
+
Aria Code will:
|
|
44
|
+
- Show the user a diff preview
|
|
45
|
+
- Ask for confirmation before writing schema.prisma
|
|
46
|
+
- Print manual `prisma migrate` commands for the user to run
|
|
47
|
+
|
|
48
|
+
You do NOT run migrations. You only propose schema file changes.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
You are Aria Code's dependency upgrade analyzer. You summarize breaking changes in major dependency upgrades.
|
|
2
|
+
|
|
3
|
+
## Your job
|
|
4
|
+
|
|
5
|
+
For each major upgrade listed below, provide a BRIEF summary of:
|
|
6
|
+
1. Key breaking changes developers need to know
|
|
7
|
+
2. Typical migration steps
|
|
8
|
+
3. Risk level for a typical project
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
|
|
12
|
+
- Be CONCISE. Developers skim this, not read it word-for-word.
|
|
13
|
+
- Focus on BREAKING changes, not new features
|
|
14
|
+
- If you don't know specific breaking changes, say so honestly
|
|
15
|
+
- Do NOT invent breaking changes
|
|
16
|
+
- Format each package as: package name, then bullet list of concerns
|
|
17
|
+
|
|
18
|
+
## Context
|
|
19
|
+
|
|
20
|
+
Major upgrades in scope:
|
|
21
|
+
{{ major_upgrades }}
|
|
22
|
+
|
|
23
|
+
Project type: {{ project_type }}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
You are Aria Code's Prisma upgrade specialist. You help developers upgrade Prisma safely.
|
|
2
|
+
|
|
3
|
+
## Current state
|
|
4
|
+
|
|
5
|
+
- Current Prisma version: {{ current_version }}
|
|
6
|
+
- Target Prisma version: {{ target_version }}
|
|
7
|
+
- Project schema: {{ schema_summary }}
|
|
8
|
+
|
|
9
|
+
## Your job
|
|
10
|
+
|
|
11
|
+
1. Identify breaking changes between {{ current_version }} and {{ target_version }}
|
|
12
|
+
2. Check the user's schema.prisma for patterns affected by breaking changes
|
|
13
|
+
3. Provide specific migration steps
|
|
14
|
+
|
|
15
|
+
## Rules
|
|
16
|
+
|
|
17
|
+
- Only mention breaking changes that actually affect this project
|
|
18
|
+
- Reference specific models/fields from the schema when relevant
|
|
19
|
+
- Be concrete: show before/after code snippets for changes
|
|
20
|
+
- If the upgrade is safe (patch/minor), say so briefly and don't over-warn
|
|
21
|
+
- NEVER suggest running `prisma migrate dev` automatically — user runs it
|
|
22
|
+
|
|
23
|
+
## Output format
|
|
24
|
+
|
|
25
|
+
1. Summary (1-2 sentences): is this upgrade safe for this project?
|
|
26
|
+
2. Breaking changes affecting this project (if any)
|
|
27
|
+
3. Specific migration steps for this project's schema
|
|
28
|
+
4. Post-upgrade verification steps
|
package/dist/provider.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ export declare class AnthropicProvider implements Provider {
|
|
|
74
74
|
*/
|
|
75
75
|
declare abstract class OpenAICompatibleProvider implements Provider {
|
|
76
76
|
abstract name: string;
|
|
77
|
+
/** Timeout for API requests in milliseconds (default: 2 minutes). */
|
|
78
|
+
protected getTimeoutMs(): number;
|
|
77
79
|
protected abstract getEndpoint(): string;
|
|
78
80
|
protected abstract getHeaders(): Record<string, string>;
|
|
79
81
|
protected abstract buildBody(messages: ProviderMessage[], tools: Tool[], options: {
|
package/dist/provider.js
CHANGED
|
@@ -162,12 +162,17 @@ export class AnthropicProvider {
|
|
|
162
162
|
* Eliminates duplicated fetch + parse + error handling logic.
|
|
163
163
|
*/
|
|
164
164
|
class OpenAICompatibleProvider {
|
|
165
|
+
/** Timeout for API requests in milliseconds (default: 2 minutes). */
|
|
166
|
+
getTimeoutMs() {
|
|
167
|
+
return 120_000;
|
|
168
|
+
}
|
|
165
169
|
async chat(messages, tools, options) {
|
|
166
170
|
try {
|
|
167
171
|
const response = await fetch(this.getEndpoint(), {
|
|
168
172
|
method: "POST",
|
|
169
173
|
headers: this.getHeaders(),
|
|
170
174
|
body: JSON.stringify(this.buildBody(messages, tools, options)),
|
|
175
|
+
signal: AbortSignal.timeout(this.getTimeoutMs()),
|
|
171
176
|
});
|
|
172
177
|
if (!response.ok) {
|
|
173
178
|
const errorData = await response.json().catch(() => ({}));
|
|
@@ -259,6 +264,7 @@ export class OllamaProvider extends OpenAICompatibleProvider {
|
|
|
259
264
|
method: "POST",
|
|
260
265
|
headers: this.getHeaders(),
|
|
261
266
|
body: JSON.stringify(this.buildBody(messages, tools, options)),
|
|
267
|
+
signal: AbortSignal.timeout(this.getTimeoutMs()),
|
|
262
268
|
});
|
|
263
269
|
if (!response.ok) {
|
|
264
270
|
const errorData = await response.json().catch(() => ({}));
|
|
@@ -318,41 +324,6 @@ export class OpenRouterProvider extends OpenAICompatibleProvider {
|
|
|
318
324
|
}
|
|
319
325
|
}
|
|
320
326
|
// ---------------------------------------------------------------------------
|
|
321
|
-
// Ollama response validation override
|
|
322
|
-
// ---------------------------------------------------------------------------
|
|
323
|
-
// Ollama uses a different response shape: { message: { content, tool_calls } }
|
|
324
|
-
// Override the chat method to handle this.
|
|
325
|
-
OllamaProvider.prototype.chat = async function (messages, tools, options) {
|
|
326
|
-
try {
|
|
327
|
-
const response = await fetch(this.getEndpoint(), {
|
|
328
|
-
method: "POST",
|
|
329
|
-
headers: this.getHeaders(),
|
|
330
|
-
body: JSON.stringify(this.buildBody(messages, tools, options)),
|
|
331
|
-
});
|
|
332
|
-
if (!response.ok) {
|
|
333
|
-
const errorData = await response.json().catch(() => ({}));
|
|
334
|
-
throw new Error(`ollama API error: ${response.status} ${response.statusText} - ${JSON.stringify(errorData)}`);
|
|
335
|
-
}
|
|
336
|
-
const data = (await response.json());
|
|
337
|
-
const message = data?.message;
|
|
338
|
-
if (!message) {
|
|
339
|
-
throw new Error("Unexpected Ollama response format: missing message");
|
|
340
|
-
}
|
|
341
|
-
const content = typeof message.content === "string" ? message.content : "";
|
|
342
|
-
const toolCalls = parseOpenAIToolCalls(Array.isArray(message.tool_calls) ? message.tool_calls : undefined);
|
|
343
|
-
return {
|
|
344
|
-
content,
|
|
345
|
-
toolCalls,
|
|
346
|
-
stopReason: mapFinishReason(undefined, toolCalls.length),
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
catch (error) {
|
|
350
|
-
if (error instanceof ProviderError)
|
|
351
|
-
throw error;
|
|
352
|
-
throw new ProviderError(`ollama API error: ${error instanceof Error ? error.message : String(error)}`, "ollama", error);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
// ---------------------------------------------------------------------------
|
|
356
327
|
// Zod → JSON Schema converter
|
|
357
328
|
// ---------------------------------------------------------------------------
|
|
358
329
|
/**
|