@ariacode/cli 0.1.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +190 -5
  2. package/dist/actions/db-ask.d.ts +16 -0
  3. package/dist/actions/db-ask.js +130 -0
  4. package/dist/actions/db-ask.js.map +1 -0
  5. package/dist/actions/db-explain.d.ts +16 -0
  6. package/dist/actions/db-explain.js +123 -0
  7. package/dist/actions/db-explain.js.map +1 -0
  8. package/dist/actions/db-migrate.d.ts +17 -0
  9. package/dist/actions/db-migrate.js +124 -0
  10. package/dist/actions/db-migrate.js.map +1 -0
  11. package/dist/actions/db-schema.d.ts +11 -0
  12. package/dist/actions/db-schema.js +38 -0
  13. package/dist/actions/db-schema.js.map +1 -0
  14. package/dist/actions/upgrade-deps.d.ts +18 -0
  15. package/dist/actions/upgrade-deps.js +227 -0
  16. package/dist/actions/upgrade-deps.js.map +1 -0
  17. package/dist/actions/upgrade-prisma.d.ts +16 -0
  18. package/dist/actions/upgrade-prisma.js +177 -0
  19. package/dist/actions/upgrade-prisma.js.map +1 -0
  20. package/dist/actions.d.ts +20 -0
  21. package/dist/actions.js +105 -36
  22. package/dist/actions.js.map +1 -1
  23. package/dist/agent.js +28 -9
  24. package/dist/agent.js.map +1 -1
  25. package/dist/cli.js +102 -0
  26. package/dist/cli.js.map +1 -1
  27. package/dist/config.d.ts +16 -0
  28. package/dist/config.js +39 -0
  29. package/dist/config.js.map +1 -1
  30. package/dist/db/client-usage.d.ts +19 -0
  31. package/dist/db/client-usage.js +107 -0
  32. package/dist/db/client-usage.js.map +1 -0
  33. package/dist/db/migrate.d.ts +26 -0
  34. package/dist/db/migrate.js +59 -0
  35. package/dist/db/migrate.js.map +1 -0
  36. package/dist/db/schema.d.ts +106 -0
  37. package/dist/db/schema.js +275 -0
  38. package/dist/db/schema.js.map +1 -0
  39. package/dist/db/summary.d.ts +12 -0
  40. package/dist/db/summary.js +133 -0
  41. package/dist/db/summary.js.map +1 -0
  42. package/dist/fs-helpers.d.ts +19 -0
  43. package/dist/fs-helpers.js +92 -0
  44. package/dist/fs-helpers.js.map +1 -0
  45. package/dist/parser.d.ts +11 -0
  46. package/dist/parser.js +102 -0
  47. package/dist/parser.js.map +1 -1
  48. package/dist/prompt-loader.d.ts +9 -0
  49. package/dist/prompt-loader.js +26 -0
  50. package/dist/prompt-loader.js.map +1 -0
  51. package/dist/prompts/db_ask.md +39 -0
  52. package/dist/prompts/db_explain.md +43 -0
  53. package/dist/prompts/db_migrate.md +48 -0
  54. package/dist/prompts/upgrade_deps.md +23 -0
  55. package/dist/prompts/upgrade_prisma.md +28 -0
  56. package/dist/provider.d.ts +9 -2
  57. package/dist/provider.js +12 -39
  58. package/dist/provider.js.map +1 -1
  59. package/dist/storage.d.ts +11 -0
  60. package/dist/storage.js +36 -4
  61. package/dist/storage.js.map +1 -1
  62. package/dist/tools.d.ts +26 -0
  63. package/dist/tools.js +256 -8
  64. package/dist/tools.js.map +1 -1
  65. package/dist/upgrade/changelog.d.ts +21 -0
  66. package/dist/upgrade/changelog.js +62 -0
  67. package/dist/upgrade/changelog.js.map +1 -0
  68. package/dist/upgrade/classifier.d.ts +25 -0
  69. package/dist/upgrade/classifier.js +78 -0
  70. package/dist/upgrade/classifier.js.map +1 -0
  71. package/dist/upgrade/outdated.d.ts +17 -0
  72. package/dist/upgrade/outdated.js +138 -0
  73. package/dist/upgrade/outdated.js.map +1 -0
  74. package/dist/upgrade/prisma-upgrade.d.ts +20 -0
  75. package/dist/upgrade/prisma-upgrade.js +66 -0
  76. package/dist/upgrade/prisma-upgrade.js.map +1 -0
  77. package/package.json +7 -4
  78. package/dist/prompts/prompts/ask.md +0 -20
  79. package/dist/prompts/prompts/explore.md +0 -38
  80. package/dist/prompts/prompts/patch.md +0 -27
  81. package/dist/prompts/prompts/plan.md +0 -41
  82. package/dist/prompts/prompts/review.md +0 -33
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Classify dependency upgrades by semver risk level.
3
+ */
4
+ import type { OutdatedPackage } from './outdated.js';
5
+ export type UpgradeRisk = 'patch' | 'minor' | 'major' | 'prerelease';
6
+ export interface ClassifiedUpgrade {
7
+ name: string;
8
+ current: string;
9
+ target: string;
10
+ risk: UpgradeRisk;
11
+ type: 'dependencies' | 'devDependencies' | 'peerDependencies';
12
+ reasoning: string;
13
+ }
14
+ /**
15
+ * Classify the risk of upgrading from `current` to `target` using semver.diff().
16
+ */
17
+ export declare function classifyUpgrade(current: string, target: string): UpgradeRisk;
18
+ /**
19
+ * Classify a list of outdated packages into risk-annotated upgrades.
20
+ */
21
+ export declare function classifyAll(packages: OutdatedPackage[]): ClassifiedUpgrade[];
22
+ /**
23
+ * Group classified upgrades by risk level.
24
+ */
25
+ export declare function groupByRisk(upgrades: ClassifiedUpgrade[]): Record<UpgradeRisk, ClassifiedUpgrade[]>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Classify dependency upgrades by semver risk level.
3
+ */
4
+ import semver from 'semver';
5
+ /**
6
+ * Classify the risk of upgrading from `current` to `target` using semver.diff().
7
+ */
8
+ export function classifyUpgrade(current, target) {
9
+ const parsedTarget = semver.parse(target) ?? semver.parse(semver.coerce(target));
10
+ const parsedCurrent = semver.parse(semver.coerce(current));
11
+ if (!parsedCurrent || !parsedTarget)
12
+ return 'major';
13
+ // If target has a prerelease tag, classify as prerelease regardless of diff
14
+ if (parsedTarget.prerelease.length > 0)
15
+ return 'prerelease';
16
+ const diff = semver.diff(parsedCurrent.version, parsedTarget.version);
17
+ if (!diff)
18
+ return 'patch'; // same version
19
+ switch (diff) {
20
+ case 'patch':
21
+ return 'patch';
22
+ case 'minor':
23
+ return 'minor';
24
+ case 'major':
25
+ case 'premajor':
26
+ return 'major';
27
+ case 'preminor':
28
+ case 'prepatch':
29
+ case 'prerelease':
30
+ return 'prerelease';
31
+ default:
32
+ return 'major';
33
+ }
34
+ }
35
+ /**
36
+ * Classify a list of outdated packages into risk-annotated upgrades.
37
+ */
38
+ export function classifyAll(packages) {
39
+ return packages.map((pkg) => {
40
+ const risk = classifyUpgrade(pkg.current, pkg.latest);
41
+ return {
42
+ name: pkg.name,
43
+ current: pkg.current,
44
+ target: pkg.latest,
45
+ risk,
46
+ type: pkg.type,
47
+ reasoning: buildReasoning(risk, pkg.current, pkg.latest),
48
+ };
49
+ });
50
+ }
51
+ /**
52
+ * Group classified upgrades by risk level.
53
+ */
54
+ export function groupByRisk(upgrades) {
55
+ const groups = {
56
+ patch: [],
57
+ minor: [],
58
+ major: [],
59
+ prerelease: [],
60
+ };
61
+ for (const u of upgrades) {
62
+ groups[u.risk].push(u);
63
+ }
64
+ return groups;
65
+ }
66
+ function buildReasoning(risk, current, target) {
67
+ switch (risk) {
68
+ case 'patch':
69
+ return `Bug fix: ${current} → ${target}`;
70
+ case 'minor':
71
+ return `New features (backward-compatible): ${current} → ${target}`;
72
+ case 'major':
73
+ return `Breaking changes possible: ${current} → ${target}`;
74
+ case 'prerelease':
75
+ return `Pre-release version: ${current} → ${target}`;
76
+ }
77
+ }
78
+ //# sourceMappingURL=classifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/upgrade/classifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAc5B;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,MAAc;IAC7D,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3D,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC;IAEpD,4EAA4E;IAC5E,IAAI,YAAY,CAAC,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,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,IAAiB,EAAE,OAAe,EAAE,MAAc;IACxE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,YAAY,OAAO,MAAM,MAAM,EAAE,CAAC;QAC3C,KAAK,OAAO;YACV,OAAO,uCAAuC,OAAO,MAAM,MAAM,EAAE,CAAC;QACtE,KAAK,OAAO;YACV,OAAO,8BAA8B,OAAO,MAAM,MAAM,EAAE,CAAC;QAC7D,KAAK,YAAY;YACf,OAAO,wBAAwB,OAAO,MAAM,MAAM,EAAE,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Run `npm/pnpm/yarn outdated --json` via subprocess and parse results.
3
+ * Read-only: never executes install or update commands.
4
+ */
5
+ export interface OutdatedPackage {
6
+ name: string;
7
+ current: string;
8
+ wanted: string;
9
+ latest: string;
10
+ type: 'dependencies' | 'devDependencies' | 'peerDependencies';
11
+ location: string;
12
+ }
13
+ /**
14
+ * Run the package manager's `outdated --json` command and return normalized results.
15
+ * npm outdated returns exit code 1 when outdated packages exist — that's expected.
16
+ */
17
+ export declare function getOutdatedPackages(projectRoot: string, packageManager: 'npm' | 'pnpm' | 'yarn' | 'bun'): Promise<OutdatedPackage[]>;
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Run `npm/pnpm/yarn outdated --json` via subprocess and parse results.
3
+ * Read-only: never executes install or update commands.
4
+ */
5
+ import { execFile } from 'node:child_process';
6
+ /**
7
+ * Run the package manager's `outdated --json` command and return normalized results.
8
+ * npm outdated returns exit code 1 when outdated packages exist — that's expected.
9
+ */
10
+ export async function getOutdatedPackages(projectRoot, packageManager) {
11
+ const { cmd, args } = buildCommand(packageManager);
12
+ const raw = await runOutdated(cmd, args, projectRoot);
13
+ if (!raw.trim())
14
+ return [];
15
+ return parseOutput(raw, packageManager);
16
+ }
17
+ function buildCommand(pm) {
18
+ switch (pm) {
19
+ case 'pnpm':
20
+ return { cmd: 'pnpm', args: ['outdated', '--json'] };
21
+ case 'yarn':
22
+ return { cmd: 'yarn', args: ['outdated', '--json'] };
23
+ case 'bun':
24
+ return { cmd: 'bun', args: ['outdated', '--json'] };
25
+ default:
26
+ return { cmd: 'npm', args: ['outdated', '--json'] };
27
+ }
28
+ }
29
+ function runOutdated(cmd, args, cwd) {
30
+ return new Promise((resolve, reject) => {
31
+ execFile(cmd, args, { cwd, timeout: 30_000 }, (error, stdout, stderr) => {
32
+ // npm outdated exits with code 1 when there are outdated packages — not an error
33
+ if (error && stdout) {
34
+ resolve(stdout);
35
+ return;
36
+ }
37
+ if (error) {
38
+ // Distinguish "command not found" from "outdated failed"
39
+ const isNotFound = error.code === 'ENOENT';
40
+ const msg = isNotFound
41
+ ? `${cmd} is not installed or not in PATH`
42
+ : `Failed to run ${cmd} outdated: ${error.message}${stderr ? ` (${stderr.trim()})` : ''}`;
43
+ reject(new Error(msg));
44
+ return;
45
+ }
46
+ resolve(stdout);
47
+ });
48
+ });
49
+ }
50
+ /**
51
+ * Parse JSON output from different package managers into a normalized format.
52
+ * Each PM has a slightly different JSON structure.
53
+ */
54
+ function parseOutput(raw, pm) {
55
+ if (pm === 'npm' || pm === 'bun')
56
+ return parseNpmOutput(raw);
57
+ if (pm === 'pnpm')
58
+ return parsePnpmOutput(raw);
59
+ return parseYarnOutput(raw);
60
+ }
61
+ /**
62
+ * npm outdated --json returns:
63
+ * { "package-name": { "current": "1.0.0", "wanted": "1.0.1", "latest": "2.0.0", "type": "dependencies", "location": "..." } }
64
+ */
65
+ function parseNpmOutput(raw) {
66
+ const data = JSON.parse(raw);
67
+ return Object.entries(data)
68
+ .filter(([, v]) => v.current && v.latest)
69
+ .map(([name, v]) => ({
70
+ name,
71
+ current: v.current,
72
+ wanted: v.wanted ?? v.current,
73
+ latest: v.latest,
74
+ type: normalizeDepType(v.type),
75
+ location: v.location ?? '',
76
+ }));
77
+ }
78
+ /**
79
+ * pnpm outdated --json returns an array:
80
+ * [{ "packageName": "...", "current": "...", "latest": "...", "wanted": "...", "dependencyType": "..." }]
81
+ */
82
+ function parsePnpmOutput(raw) {
83
+ const data = JSON.parse(raw);
84
+ const list = Array.isArray(data) ? data : [];
85
+ return list
86
+ .filter((p) => p.current && p.latest)
87
+ .map((p) => ({
88
+ name: p.packageName ?? p.name ?? '',
89
+ current: p.current,
90
+ wanted: p.wanted ?? p.current,
91
+ latest: p.latest,
92
+ type: normalizeDepType(p.dependencyType ?? p.type),
93
+ location: p.location ?? '',
94
+ }));
95
+ }
96
+ /**
97
+ * yarn outdated --json outputs newline-delimited JSON.
98
+ * The "data" table row format: [name, current, wanted, latest, type, url]
99
+ */
100
+ function parseYarnOutput(raw) {
101
+ const results = [];
102
+ for (const line of raw.split('\n')) {
103
+ if (!line.trim())
104
+ continue;
105
+ try {
106
+ const obj = JSON.parse(line);
107
+ if (obj.type === 'table' && obj.data?.body) {
108
+ for (const row of obj.data.body) {
109
+ if (row.length >= 5) {
110
+ results.push({
111
+ name: row[0],
112
+ current: row[1],
113
+ wanted: row[2],
114
+ latest: row[3],
115
+ type: normalizeDepType(row[4]),
116
+ location: '',
117
+ });
118
+ }
119
+ }
120
+ }
121
+ }
122
+ catch {
123
+ // skip non-JSON lines
124
+ }
125
+ }
126
+ return results;
127
+ }
128
+ function normalizeDepType(raw) {
129
+ if (!raw)
130
+ return 'dependencies';
131
+ const lower = raw.toLowerCase();
132
+ if (lower.includes('dev'))
133
+ return 'devDependencies';
134
+ if (lower.includes('peer'))
135
+ return 'peerDependencies';
136
+ return 'dependencies';
137
+ }
138
+ //# sourceMappingURL=outdated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outdated.js","sourceRoot":"","sources":["../../src/upgrade/outdated.ts"],"names":[],"mappings":"AAA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*/
5
+ import { type UpgradeRisk } from './classifier.js';
6
+ export interface PrismaVersionInfo {
7
+ currentPrisma: string;
8
+ currentClient: string;
9
+ latestVersion: string;
10
+ risk: UpgradeRisk;
11
+ hasPrisma: boolean;
12
+ }
13
+ /**
14
+ * Detect current Prisma versions from package.json and fetch latest from npm registry.
15
+ */
16
+ export declare function getPrismaVersionInfo(projectRoot: string): Promise<PrismaVersionInfo>;
17
+ /**
18
+ * Fetch the latest version of a package from npm registry.
19
+ */
20
+ export declare function fetchLatestVersion(packageName: string): Promise<string>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Prisma-specific upgrade logic.
3
+ * Detects current Prisma version, fetches latest, classifies risk.
4
+ */
5
+ import { execFile } from 'node:child_process';
6
+ import { join } from 'node:path';
7
+ import { classifyUpgrade } from './classifier.js';
8
+ import { readJsonFile } from '../fs-helpers.js';
9
+ /**
10
+ * Detect current Prisma versions from package.json and fetch latest from npm registry.
11
+ */
12
+ export async function getPrismaVersionInfo(projectRoot) {
13
+ const pkgPath = join(projectRoot, 'package.json');
14
+ const pkg = readJsonFile(pkgPath);
15
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
16
+ const hasPrisma = Boolean(deps.prisma || deps['@prisma/client']);
17
+ if (!hasPrisma) {
18
+ return { currentPrisma: '', currentClient: '', latestVersion: '', risk: 'patch', hasPrisma: false };
19
+ }
20
+ const currentPrisma = stripRange(deps.prisma ?? '');
21
+ const currentClient = stripRange(deps['@prisma/client'] ?? '');
22
+ const current = currentPrisma || currentClient;
23
+ const latestVersion = await fetchLatestVersion('prisma');
24
+ const risk = current && latestVersion ? classifyUpgrade(current, latestVersion) : 'major';
25
+ return { currentPrisma, currentClient, latestVersion, risk, hasPrisma };
26
+ }
27
+ /**
28
+ * Fetch the latest version of a package from npm registry.
29
+ */
30
+ export async function fetchLatestVersion(packageName) {
31
+ try {
32
+ const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`, {
33
+ signal: AbortSignal.timeout(10_000),
34
+ });
35
+ if (!res.ok) {
36
+ // Drain the response body to free the connection
37
+ await res.text().catch(() => { });
38
+ throw new Error(`HTTP ${res.status}`);
39
+ }
40
+ const data = await res.json();
41
+ const version = data && typeof data === 'object' && 'version' in data && typeof data.version === 'string'
42
+ ? data.version
43
+ : '';
44
+ return version;
45
+ }
46
+ catch {
47
+ // Fallback: use npm view via subprocess
48
+ return npmViewVersion(packageName);
49
+ }
50
+ }
51
+ function npmViewVersion(packageName) {
52
+ return new Promise((resolve) => {
53
+ execFile('npm', ['view', packageName, 'version'], { timeout: 10_000 }, (error, stdout) => {
54
+ if (error || !stdout.trim()) {
55
+ resolve('');
56
+ return;
57
+ }
58
+ resolve(stdout.trim());
59
+ });
60
+ });
61
+ }
62
+ /** Strip semver range prefixes like ^, ~, >= */
63
+ function stripRange(version) {
64
+ return version.replace(/^[\^~>=<]+/, '').trim();
65
+ }
66
+ //# sourceMappingURL=prisma-upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-upgrade.js","sourceRoot":"","sources":["../../src/upgrade/prisma-upgrade.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAoB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,WAAmB;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAwB,CAAC;IACzD,MAAM,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,GAAG,CAAC,eAAe,EAAE,CAAC;IAE7D,MAAM,SAAS,GAAG,OAAO,CAA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,CAAC;QACD,MAAM,IAAI,GAAY,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,IAAI,IAAI,IAAI,OAAQ,IAAgC,CAAC,OAAO,KAAK,QAAQ;YACpI,CAAC,CAAE,IAA+B,CAAC,OAAO;YAC1C,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,wCAAwC;QACxC,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,WAAmB;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YACvF,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC5B,OAAO,CAAC,EAAE,CAAC,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gDAAgD;AAChD,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ariacode/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.2",
4
4
  "description": "A predictable coding agent for Next.js, Nest.js, Prisma and Node.js projects.",
5
5
  "homepage": "https://www.ariacode.run",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/ariacodeai/ariacode.git"
8
+ "url": "git+https://github.com/ariacodeai/ariacode.git"
9
9
  },
10
10
  "bugs": {
11
11
  "url": "https://github.com/ariacodeai/ariacode/issues"
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "type": "module",
18
18
  "bin": {
19
- "aria": "./dist/cli.js"
19
+ "aria": "dist/cli.js"
20
20
  },
21
21
  "files": [
22
22
  "dist",
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "scripts": {
38
38
  "dev": "tsx src/cli.ts",
39
- "build": "tsc && cp -r src/prompts dist/prompts",
39
+ "build": "rm -rf dist && tsc && cp -r src/prompts dist/prompts",
40
40
  "start": "node dist/cli.js",
41
41
  "check": "tsc --noEmit",
42
42
  "format": "prettier --write .",
@@ -49,12 +49,14 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@anthropic-ai/sdk": "^0.82.0",
52
+ "@mrleebo/prisma-ast": "^0.15.0",
52
53
  "better-sqlite3": "^12.8.0",
53
54
  "cli-table3": "^0.6.5",
54
55
  "diff": "^8.0.4",
55
56
  "ignore": "^7.0.5",
56
57
  "picocolors": "^1.1.1",
57
58
  "prompts": "^2.4.2",
59
+ "semver": "^7.6.0",
58
60
  "smol-toml": "^1.3.1",
59
61
  "zod": "^4.3.6"
60
62
  },
@@ -63,6 +65,7 @@
63
65
  "@types/diff": "^6.0.0",
64
66
  "@types/node": "^24.3.0",
65
67
  "@types/prompts": "^2.4.9",
68
+ "@types/semver": "^7.5.0",
66
69
  "@vitest/coverage-v8": "^4.1.2",
67
70
  "fast-check": "^3.22.0",
68
71
  "prettier": "^3.8.1",
@@ -1,20 +0,0 @@
1
- You are Aria Code, a coding assistant for {{projectType}} projects.
2
-
3
- Project: {{projectRoot}}
4
- Framework: {{frameworkInfo}}
5
- Has Prisma: {{hasPrisma}}
6
-
7
- You are in read-only mode. Do NOT propose or apply any file changes.
8
-
9
- Answer the user's question using the available read-only tools to explore the codebase:
10
- - read_file: Read file content by path
11
- - list_directory: List directory contents
12
- - search_code: Search code using ripgrep
13
- - read_package_json: Parse and return package.json
14
- - read_prisma_schema: Read Prisma schema (when available)
15
-
16
- Guidelines:
17
- - Be concise and direct — avoid unnecessary preamble
18
- - Cite specific files and line numbers when relevant
19
- - If something is unclear or missing, say so explicitly
20
- - Do not speculate about code you haven't read
@@ -1,38 +0,0 @@
1
- You are Aria Code, a repository exploration assistant.
2
-
3
- Project: {{projectRoot}}
4
-
5
- Scan the repository structure, detect frameworks, identify entry points, and summarize the architecture.
6
-
7
- Use the available read-only tools:
8
- - list_directory: Scan directory structure (respect .gitignore)
9
- - read_file: Read key configuration and source files
10
- - search_code: Search for patterns, exports, and entry points
11
- - read_package_json: Detect dependencies and scripts
12
- - read_prisma_schema: Read Prisma schema (when available)
13
-
14
- Return your findings using this format:
15
-
16
- # Repository Exploration
17
-
18
- ## Project Type
19
- (detected framework and version, e.g. Next.js 14 with App Router)
20
-
21
- ## Key Files
22
- - (path): (purpose)
23
-
24
- ## Entry Points
25
- - (path): (description of what starts here)
26
-
27
- ## Structure
28
- (summary of directory layout and how the codebase is organized)
29
-
30
- ## Notable Patterns
31
- - (architectural patterns, conventions, or design decisions observed)
32
-
33
- Guidelines:
34
- - Respect .gitignore — do not list node_modules, .git, or ignored files
35
- - Identify framework-specific conventions (routing, config, middleware)
36
- - Note Prisma schema if present
37
- - Highlight any unusual or noteworthy patterns
38
- - Be concise — focus on what a new developer needs to understand the codebase
@@ -1,27 +0,0 @@
1
- You are Aria Code, a coding agent for {{projectType}} projects.
2
-
3
- Project: {{projectRoot}}
4
- Framework: {{frameworkInfo}}
5
- Has Prisma: {{hasPrisma}}
6
-
7
- Workflow:
8
- 1. Analyze the repository using read-only tools to understand the current state
9
- 2. Call propose_diff to generate a unified diff of the required changes
10
- 3. The diff will be reviewed and a MutationSummary will be built from it
11
- 4. If confirmed, call apply_diff to apply the changes atomically
12
-
13
- Available tools:
14
- - read_file: Read file content by path
15
- - list_directory: List directory contents
16
- - search_code: Search code using ripgrep
17
- - read_package_json: Parse and return package.json
18
- - read_prisma_schema: Read Prisma schema (when available)
19
- - propose_diff: Generate a unified diff without applying changes
20
- - apply_diff: Apply a previously proposed diff atomically
21
-
22
- Guidelines:
23
- - Read relevant files before proposing changes
24
- - Be precise and minimal — only change what is necessary
25
- - Produce valid unified diff format in propose_diff calls
26
- - Include rollback hints when proposing changes
27
- - Do not apply changes until explicitly confirmed
@@ -1,41 +0,0 @@
1
- You are Aria Code, a planning assistant for {{projectType}} projects.
2
-
3
- Project: {{projectRoot}}
4
- Framework: {{frameworkInfo}}
5
- Has Prisma: {{hasPrisma}}
6
-
7
- You are in read-only mode. Do NOT propose or apply any file changes.
8
-
9
- Use the available read-only tools to explore the codebase before generating a plan:
10
- - read_file: Read file content by path
11
- - list_directory: List directory contents
12
- - search_code: Search code using ripgrep
13
- - read_package_json: Parse and return package.json
14
- - read_prisma_schema: Read Prisma schema (when available)
15
-
16
- Generate a structured implementation plan using this format:
17
-
18
- # Implementation Plan
19
-
20
- ## Goal
21
- {{userGoal}}
22
-
23
- ## Steps
24
- 1. (first step)
25
- 2. (second step)
26
- ...
27
-
28
- ## Affected Files
29
- - (file path and reason)
30
-
31
- ## Risks
32
- - (potential issues or breaking changes)
33
-
34
- ## Implementation Notes
35
- (additional context, caveats, or dependencies)
36
-
37
- Guidelines:
38
- - Explore the codebase thoroughly before planning
39
- - Order steps logically with dependencies respected
40
- - Flag any risks or breaking changes explicitly
41
- - Keep the plan actionable and specific
@@ -1,33 +0,0 @@
1
- You are Aria Code, a code review assistant for {{projectType}} projects.
2
-
3
- Project: {{projectRoot}}
4
- Framework: {{frameworkInfo}}
5
- Has Prisma: {{hasPrisma}}
6
-
7
- You are in read-only mode. Analyze the provided diff and return a structured review.
8
-
9
- Use read-only tools to explore additional context when needed:
10
- - read_file: Read file content for surrounding context
11
- - search_code: Search for related patterns or usages
12
- - read_package_json: Check dependencies and scripts
13
-
14
- Return your review using this format:
15
-
16
- # Code Review
17
-
18
- ## Summary
19
- (brief overview of what the diff does)
20
-
21
- ## Issues
22
- - [HIGH] (critical bugs, security vulnerabilities, data loss risks)
23
- - [MEDIUM] (logic errors, missing error handling, performance concerns)
24
- - [LOW] (style inconsistencies, minor improvements)
25
-
26
- ## Suggestions
27
- - (non-blocking improvements or alternatives to consider)
28
-
29
- Guidelines:
30
- - Focus on correctness, security, and maintainability
31
- - Reference specific line numbers or file paths when citing issues
32
- - Distinguish between blocking issues and optional suggestions
33
- - Consider the project's framework conventions when reviewing