aether-code 0.36.7 → 0.37.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/LICENSE +21 -21
- package/README.md +0 -2
- package/bin/aether-code.js +514 -516
- package/package.json +75 -77
- package/skills/adult-creative-writing.md +60 -60
- package/skills/debugging.md +51 -51
- package/skills/game-modding.md +73 -73
- package/skills/reverse-engineering.md +41 -41
- package/skills/scraping-automation.md +77 -77
- package/skills/security-research.md +67 -67
- package/src/agent.js +38 -170
- package/src/api.js +8 -18
- package/src/box-input.js +36 -140
- package/src/config.js +38 -38
- package/src/diff.js +49 -49
- package/src/ink-input.js +91 -91
- package/src/mcp-cli.js +94 -94
- package/src/mcp-registry.js +266 -266
- package/src/mcp.js +260 -259
- package/src/menu.js +83 -83
- package/src/project-context.js +279 -0
- package/src/render.js +69 -136
- package/src/repl.js +219 -207
- package/src/sessions.js +167 -0
- package/src/setup.js +141 -139
- package/src/tools.js +942 -911
- package/src/update-check.js +7 -64
- package/src/version.js +15 -0
- package/scripts/postinstall.js +0 -182
package/src/menu.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
// Interactive multiple-choice menu — arrow/number selectable, cmd.exe-safe.
|
|
2
|
-
//
|
|
3
|
-
// Deliberately NOT Ink (which ghosts in the legacy Windows console). Uses a
|
|
4
|
-
// simple manual redraw: print the list, and on each keypress move the cursor
|
|
5
|
-
// back up to the top of the menu (ESC[nA) and clear-to-end (ESC[J), then
|
|
6
|
-
// reprint. That's the same VT layer that already renders our ANSI colours, so
|
|
7
|
-
// it works in cmd.exe, Windows Terminal, and POSIX terminals alike.
|
|
8
|
-
//
|
|
9
|
-
// Returns the chosen option object ({label, description}), or null if cancelled.
|
|
10
|
-
|
|
11
|
-
import readline from "node:readline";
|
|
12
|
-
import { c } from "./render.js";
|
|
13
|
-
|
|
14
|
-
const ellip = (s, n) => (s && s.length > n ? s.slice(0, n - 1) + "…" : s || "");
|
|
15
|
-
|
|
16
|
-
export function promptChoice({ question, options }) {
|
|
17
|
-
const opts = (options || [])
|
|
18
|
-
.map((o) => (typeof o === "string" ? { label: o } : o))
|
|
19
|
-
.filter((o) => o && o.label);
|
|
20
|
-
|
|
21
|
-
return new Promise((resolve) => {
|
|
22
|
-
// Non-interactive (piped / CI): pick the first option so automation never
|
|
23
|
-
// hangs waiting on a keypress that can't come. Print a note so it's visible.
|
|
24
|
-
if (!process.stdin.isTTY || opts.length === 0) {
|
|
25
|
-
const pick = opts[0] ?? null;
|
|
26
|
-
if (pick) process.stdout.write(c.cyan("● ") + c.bold(question) + c.gray(` → ${pick.label} (auto)\n`));
|
|
27
|
-
resolve(pick);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let sel = 0;
|
|
32
|
-
const total = opts.length + 3; // question line + options + blank + hint line
|
|
33
|
-
|
|
34
|
-
const draw = (first) => {
|
|
35
|
-
if (!first) process.stdout.write(`\x1b[${total}A`); // cursor up to menu top
|
|
36
|
-
process.stdout.write("\x1b[J"); // clear from cursor to end of screen
|
|
37
|
-
process.stdout.write(c.cyan("● ") + c.bold(question) + "\n");
|
|
38
|
-
opts.forEach((o, i) => {
|
|
39
|
-
const active = i === sel;
|
|
40
|
-
const pointer = active ? c.cyan("→") : " ";
|
|
41
|
-
const num = active ? c.cyan(c.bold(`${i + 1}.`)) : c.gray(`${i + 1}.`);
|
|
42
|
-
const label = active ? c.bold(o.label) : o.label;
|
|
43
|
-
const desc = o.description ? c.gray(" " + ellip(o.description, 60)) : "";
|
|
44
|
-
process.stdout.write(` ${pointer} ${num} ${label}${desc}\n`);
|
|
45
|
-
});
|
|
46
|
-
process.stdout.write("\n" + c.gray(" ↑/↓ move · 1-9 pick · Enter select · Esc cancel") + "\n");
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const cleanup = () => {
|
|
50
|
-
process.stdin.removeListener("keypress", onKey);
|
|
51
|
-
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
52
|
-
process.stdin.pause();
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const finish = (result) => {
|
|
56
|
-
cleanup();
|
|
57
|
-
// Collapse the menu to a compact answer line so the transcript stays clean.
|
|
58
|
-
process.stdout.write(`\x1b[${total}A\x1b[J`);
|
|
59
|
-
process.stdout.write(c.cyan("● ") + c.bold(question) + "\n");
|
|
60
|
-
if (result) process.stdout.write(" " + c.cyan("→") + " " + c.green(result.label) + "\n\n");
|
|
61
|
-
else process.stdout.write(" " + c.gray("(cancelled — proceeding with best judgment)") + "\n\n");
|
|
62
|
-
resolve(result);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const onKey = (str, key) => {
|
|
66
|
-
if (!key) return;
|
|
67
|
-
if (key.name === "up" || key.name === "k") { sel = (sel - 1 + opts.length) % opts.length; draw(false); }
|
|
68
|
-
else if (key.name === "down" || key.name === "j" || key.name === "tab") { sel = (sel + 1) % opts.length; draw(false); }
|
|
69
|
-
else if (str && /^[1-9]$/.test(str)) {
|
|
70
|
-
const i = parseInt(str, 10) - 1;
|
|
71
|
-
if (i < opts.length) finish(opts[i]);
|
|
72
|
-
}
|
|
73
|
-
else if (key.name === "return") finish(opts[sel]);
|
|
74
|
-
else if (key.name === "escape" || (key.ctrl && key.name === "c")) finish(null);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
readline.emitKeypressEvents(process.stdin);
|
|
78
|
-
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
79
|
-
process.stdin.resume();
|
|
80
|
-
process.stdin.on("keypress", onKey);
|
|
81
|
-
draw(true);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
1
|
+
// Interactive multiple-choice menu — arrow/number selectable, cmd.exe-safe.
|
|
2
|
+
//
|
|
3
|
+
// Deliberately NOT Ink (which ghosts in the legacy Windows console). Uses a
|
|
4
|
+
// simple manual redraw: print the list, and on each keypress move the cursor
|
|
5
|
+
// back up to the top of the menu (ESC[nA) and clear-to-end (ESC[J), then
|
|
6
|
+
// reprint. That's the same VT layer that already renders our ANSI colours, so
|
|
7
|
+
// it works in cmd.exe, Windows Terminal, and POSIX terminals alike.
|
|
8
|
+
//
|
|
9
|
+
// Returns the chosen option object ({label, description}), or null if cancelled.
|
|
10
|
+
|
|
11
|
+
import readline from "node:readline";
|
|
12
|
+
import { c } from "./render.js";
|
|
13
|
+
|
|
14
|
+
const ellip = (s, n) => (s && s.length > n ? s.slice(0, n - 1) + "…" : s || "");
|
|
15
|
+
|
|
16
|
+
export function promptChoice({ question, options }) {
|
|
17
|
+
const opts = (options || [])
|
|
18
|
+
.map((o) => (typeof o === "string" ? { label: o } : o))
|
|
19
|
+
.filter((o) => o && o.label);
|
|
20
|
+
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
// Non-interactive (piped / CI): pick the first option so automation never
|
|
23
|
+
// hangs waiting on a keypress that can't come. Print a note so it's visible.
|
|
24
|
+
if (!process.stdin.isTTY || opts.length === 0) {
|
|
25
|
+
const pick = opts[0] ?? null;
|
|
26
|
+
if (pick) process.stdout.write(c.cyan("● ") + c.bold(question) + c.gray(` → ${pick.label} (auto)\n`));
|
|
27
|
+
resolve(pick);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let sel = 0;
|
|
32
|
+
const total = opts.length + 3; // question line + options + blank + hint line
|
|
33
|
+
|
|
34
|
+
const draw = (first) => {
|
|
35
|
+
if (!first) process.stdout.write(`\x1b[${total}A`); // cursor up to menu top
|
|
36
|
+
process.stdout.write("\x1b[J"); // clear from cursor to end of screen
|
|
37
|
+
process.stdout.write(c.cyan("● ") + c.bold(question) + "\n");
|
|
38
|
+
opts.forEach((o, i) => {
|
|
39
|
+
const active = i === sel;
|
|
40
|
+
const pointer = active ? c.cyan("→") : " ";
|
|
41
|
+
const num = active ? c.cyan(c.bold(`${i + 1}.`)) : c.gray(`${i + 1}.`);
|
|
42
|
+
const label = active ? c.bold(o.label) : o.label;
|
|
43
|
+
const desc = o.description ? c.gray(" " + ellip(o.description, 60)) : "";
|
|
44
|
+
process.stdout.write(` ${pointer} ${num} ${label}${desc}\n`);
|
|
45
|
+
});
|
|
46
|
+
process.stdout.write("\n" + c.gray(" ↑/↓ move · 1-9 pick · Enter select · Esc cancel") + "\n");
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const cleanup = () => {
|
|
50
|
+
process.stdin.removeListener("keypress", onKey);
|
|
51
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(false);
|
|
52
|
+
process.stdin.pause();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const finish = (result) => {
|
|
56
|
+
cleanup();
|
|
57
|
+
// Collapse the menu to a compact answer line so the transcript stays clean.
|
|
58
|
+
process.stdout.write(`\x1b[${total}A\x1b[J`);
|
|
59
|
+
process.stdout.write(c.cyan("● ") + c.bold(question) + "\n");
|
|
60
|
+
if (result) process.stdout.write(" " + c.cyan("→") + " " + c.green(result.label) + "\n\n");
|
|
61
|
+
else process.stdout.write(" " + c.gray("(cancelled — proceeding with best judgment)") + "\n\n");
|
|
62
|
+
resolve(result);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const onKey = (str, key) => {
|
|
66
|
+
if (!key) return;
|
|
67
|
+
if (key.name === "up" || key.name === "k") { sel = (sel - 1 + opts.length) % opts.length; draw(false); }
|
|
68
|
+
else if (key.name === "down" || key.name === "j" || key.name === "tab") { sel = (sel + 1) % opts.length; draw(false); }
|
|
69
|
+
else if (str && /^[1-9]$/.test(str)) {
|
|
70
|
+
const i = parseInt(str, 10) - 1;
|
|
71
|
+
if (i < opts.length) finish(opts[i]);
|
|
72
|
+
}
|
|
73
|
+
else if (key.name === "return") finish(opts[sel]);
|
|
74
|
+
else if (key.name === "escape" || (key.ctrl && key.name === "c")) finish(null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
readline.emitKeypressEvents(process.stdin);
|
|
78
|
+
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
79
|
+
process.stdin.resume();
|
|
80
|
+
process.stdin.on("keypress", onKey);
|
|
81
|
+
draw(true);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// Project context scanner. Reads the cwd on startup to give the model
|
|
2
|
+
// immediate understanding of what project it's working in — tech stack,
|
|
3
|
+
// file structure, available scripts, dependencies, and any project-specific
|
|
4
|
+
// instructions. This is the single biggest quality-of-life improvement for
|
|
5
|
+
// a weaker model: instead of guessing, it KNOWS.
|
|
6
|
+
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
|
|
10
|
+
const SKIP_DIRS = new Set([
|
|
11
|
+
"node_modules", ".git", ".next", "dist", "build", "__pycache__",
|
|
12
|
+
".venv", "venv", "env", ".env", ".idea", ".vscode", "coverage",
|
|
13
|
+
".cache", ".turbo", "target", "out", ".output", ".nuxt", ".svelte-kit",
|
|
14
|
+
"vendor", "bower_components", ".parcel-cache", ".webpack",
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const FRAMEWORK_SIGNATURES = {
|
|
18
|
+
"next.config.js": "Next.js",
|
|
19
|
+
"next.config.mjs": "Next.js",
|
|
20
|
+
"next.config.ts": "Next.js",
|
|
21
|
+
"nuxt.config.ts": "Nuxt",
|
|
22
|
+
"svelte.config.js": "SvelteKit",
|
|
23
|
+
"astro.config.mjs": "Astro",
|
|
24
|
+
"remix.config.js": "Remix",
|
|
25
|
+
"angular.json": "Angular",
|
|
26
|
+
"vue.config.js": "Vue CLI",
|
|
27
|
+
"vite.config.ts": "Vite",
|
|
28
|
+
"vite.config.js": "Vite",
|
|
29
|
+
"webpack.config.js": "Webpack",
|
|
30
|
+
"tsconfig.json": "TypeScript",
|
|
31
|
+
"Cargo.toml": "Rust (Cargo)",
|
|
32
|
+
"go.mod": "Go",
|
|
33
|
+
"pyproject.toml": "Python",
|
|
34
|
+
"setup.py": "Python (setuptools)",
|
|
35
|
+
"requirements.txt": "Python",
|
|
36
|
+
"Gemfile": "Ruby (Bundler)",
|
|
37
|
+
"pom.xml": "Java (Maven)",
|
|
38
|
+
"build.gradle": "Java/Kotlin (Gradle)",
|
|
39
|
+
"CMakeLists.txt": "C/C++ (CMake)",
|
|
40
|
+
"Makefile": "Make",
|
|
41
|
+
"Dockerfile": "Docker",
|
|
42
|
+
"docker-compose.yml": "Docker Compose",
|
|
43
|
+
"docker-compose.yaml": "Docker Compose",
|
|
44
|
+
".env": "dotenv config",
|
|
45
|
+
"prisma/schema.prisma": "Prisma ORM",
|
|
46
|
+
"drizzle.config.ts": "Drizzle ORM",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const DEP_FRAMEWORKS = {
|
|
50
|
+
next: "Next.js",
|
|
51
|
+
react: "React",
|
|
52
|
+
vue: "Vue",
|
|
53
|
+
svelte: "Svelte",
|
|
54
|
+
angular: "Angular",
|
|
55
|
+
express: "Express",
|
|
56
|
+
fastify: "Fastify",
|
|
57
|
+
koa: "Koa",
|
|
58
|
+
hono: "Hono",
|
|
59
|
+
"socket.io": "Socket.IO",
|
|
60
|
+
prisma: "Prisma",
|
|
61
|
+
drizzle: "Drizzle",
|
|
62
|
+
mongoose: "Mongoose",
|
|
63
|
+
sequelize: "Sequelize",
|
|
64
|
+
tailwindcss: "Tailwind CSS",
|
|
65
|
+
"styled-components": "styled-components",
|
|
66
|
+
electron: "Electron",
|
|
67
|
+
jest: "Jest",
|
|
68
|
+
vitest: "Vitest",
|
|
69
|
+
mocha: "Mocha",
|
|
70
|
+
playwright: "Playwright",
|
|
71
|
+
cypress: "Cypress",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function readJsonSafe(filePath) {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function readTextSafe(filePath, maxBytes = 2000) {
|
|
83
|
+
try {
|
|
84
|
+
const stat = fs.statSync(filePath);
|
|
85
|
+
if (!stat.isFile() || stat.size > 500_000) return null;
|
|
86
|
+
const buf = Buffer.alloc(Math.min(stat.size, maxBytes));
|
|
87
|
+
const fd = fs.openSync(filePath, "r");
|
|
88
|
+
const bytesRead = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
89
|
+
fs.closeSync(fd);
|
|
90
|
+
return buf.toString("utf8", 0, bytesRead);
|
|
91
|
+
} catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function listTopLevel(cwd) {
|
|
97
|
+
let entries;
|
|
98
|
+
try {
|
|
99
|
+
entries = fs.readdirSync(cwd, { withFileTypes: true });
|
|
100
|
+
} catch {
|
|
101
|
+
return { dirs: [], files: [] };
|
|
102
|
+
}
|
|
103
|
+
const dirs = [];
|
|
104
|
+
const files = [];
|
|
105
|
+
for (const e of entries) {
|
|
106
|
+
if (e.name.startsWith(".") && e.name !== ".env" && e.name !== ".gitignore") continue;
|
|
107
|
+
if (SKIP_DIRS.has(e.name)) continue;
|
|
108
|
+
if (e.isDirectory()) {
|
|
109
|
+
dirs.push(e.name + "/");
|
|
110
|
+
} else if (e.isFile()) {
|
|
111
|
+
files.push(e.name);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
dirs.sort();
|
|
115
|
+
files.sort();
|
|
116
|
+
return { dirs, files };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function listSecondLevel(cwd, dirName) {
|
|
120
|
+
const full = path.join(cwd, dirName);
|
|
121
|
+
let entries;
|
|
122
|
+
try {
|
|
123
|
+
entries = fs.readdirSync(full, { withFileTypes: true });
|
|
124
|
+
} catch {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
const items = [];
|
|
128
|
+
for (const e of entries) {
|
|
129
|
+
if (e.name.startsWith(".")) continue;
|
|
130
|
+
if (SKIP_DIRS.has(e.name)) continue;
|
|
131
|
+
items.push(e.isDirectory() ? e.name + "/" : e.name);
|
|
132
|
+
}
|
|
133
|
+
items.sort();
|
|
134
|
+
return items.slice(0, 30);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function detectFrameworks(cwd, topFiles) {
|
|
138
|
+
const found = new Set();
|
|
139
|
+
for (const file of topFiles) {
|
|
140
|
+
if (FRAMEWORK_SIGNATURES[file]) found.add(FRAMEWORK_SIGNATURES[file]);
|
|
141
|
+
}
|
|
142
|
+
if (fs.existsSync(path.join(cwd, "prisma", "schema.prisma"))) {
|
|
143
|
+
found.add("Prisma ORM");
|
|
144
|
+
}
|
|
145
|
+
return [...found];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function extractPackageInfo(cwd) {
|
|
149
|
+
const pkg = readJsonSafe(path.join(cwd, "package.json"));
|
|
150
|
+
if (!pkg) return null;
|
|
151
|
+
const info = { name: pkg.name, version: pkg.version };
|
|
152
|
+
if (pkg.scripts && Object.keys(pkg.scripts).length > 0) {
|
|
153
|
+
info.scripts = Object.keys(pkg.scripts);
|
|
154
|
+
}
|
|
155
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
156
|
+
const detectedLibs = [];
|
|
157
|
+
for (const [dep, label] of Object.entries(DEP_FRAMEWORKS)) {
|
|
158
|
+
if (allDeps[dep]) detectedLibs.push(label);
|
|
159
|
+
}
|
|
160
|
+
if (detectedLibs.length > 0) info.frameworks = detectedLibs;
|
|
161
|
+
const depCount = Object.keys(pkg.dependencies || {}).length;
|
|
162
|
+
const devCount = Object.keys(pkg.devDependencies || {}).length;
|
|
163
|
+
if (depCount || devCount) {
|
|
164
|
+
info.depCounts = `${depCount} deps, ${devCount} devDeps`;
|
|
165
|
+
}
|
|
166
|
+
return info;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function extractCargoInfo(cwd) {
|
|
170
|
+
const raw = readTextSafe(path.join(cwd, "Cargo.toml"), 1500);
|
|
171
|
+
if (!raw) return null;
|
|
172
|
+
const name = raw.match(/^name\s*=\s*"(.+?)"/m)?.[1];
|
|
173
|
+
const version = raw.match(/^version\s*=\s*"(.+?)"/m)?.[1];
|
|
174
|
+
return { name, version, type: "Rust" };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function extractGoInfo(cwd) {
|
|
178
|
+
const raw = readTextSafe(path.join(cwd, "go.mod"), 500);
|
|
179
|
+
if (!raw) return null;
|
|
180
|
+
const mod = raw.match(/^module\s+(\S+)/m)?.[1];
|
|
181
|
+
const goVer = raw.match(/^go\s+(\S+)/m)?.[1];
|
|
182
|
+
return { module: mod, goVersion: goVer, type: "Go" };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function extractPythonInfo(cwd) {
|
|
186
|
+
const pyproject = readTextSafe(path.join(cwd, "pyproject.toml"), 1500);
|
|
187
|
+
if (pyproject) {
|
|
188
|
+
const name = pyproject.match(/^name\s*=\s*"(.+?)"/m)?.[1];
|
|
189
|
+
return { name, type: "Python" };
|
|
190
|
+
}
|
|
191
|
+
if (fs.existsSync(path.join(cwd, "requirements.txt"))) {
|
|
192
|
+
return { type: "Python (requirements.txt)" };
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function scanProject(cwd) {
|
|
198
|
+
const { dirs, files } = listTopLevel(cwd);
|
|
199
|
+
if (dirs.length === 0 && files.length === 0) {
|
|
200
|
+
return "[project]\nEmpty directory — no files detected.\n[/project]\n";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const lines = ["[project]"];
|
|
204
|
+
|
|
205
|
+
const frameworks = detectFrameworks(cwd, files);
|
|
206
|
+
if (frameworks.length > 0) {
|
|
207
|
+
lines.push(`stack: ${frameworks.join(", ")}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const pkg = extractPackageInfo(cwd);
|
|
211
|
+
const cargo = extractCargoInfo(cwd);
|
|
212
|
+
const goInfo = extractGoInfo(cwd);
|
|
213
|
+
const pyInfo = extractPythonInfo(cwd);
|
|
214
|
+
|
|
215
|
+
if (pkg) {
|
|
216
|
+
if (pkg.name) lines.push(`package: ${pkg.name}${pkg.version ? `@${pkg.version}` : ""}`);
|
|
217
|
+
if (pkg.frameworks) lines.push(`libraries: ${pkg.frameworks.join(", ")}`);
|
|
218
|
+
if (pkg.depCounts) lines.push(`dependencies: ${pkg.depCounts}`);
|
|
219
|
+
if (pkg.scripts) lines.push(`scripts: ${pkg.scripts.join(", ")}`);
|
|
220
|
+
}
|
|
221
|
+
if (cargo) {
|
|
222
|
+
lines.push(`crate: ${cargo.name || "unknown"}${cargo.version ? `@${cargo.version}` : ""}`);
|
|
223
|
+
}
|
|
224
|
+
if (goInfo) {
|
|
225
|
+
lines.push(`module: ${goInfo.module || "unknown"}${goInfo.goVersion ? ` (go ${goInfo.goVersion})` : ""}`);
|
|
226
|
+
}
|
|
227
|
+
if (pyInfo) {
|
|
228
|
+
lines.push(`python project: ${pyInfo.name || pyInfo.type}`);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
lines.push("");
|
|
232
|
+
lines.push("structure:");
|
|
233
|
+
for (const d of dirs) {
|
|
234
|
+
lines.push(` ${d}`);
|
|
235
|
+
const children = listSecondLevel(cwd, d.replace(/\/$/, ""));
|
|
236
|
+
for (const child of children.slice(0, 15)) {
|
|
237
|
+
lines.push(` ${child}`);
|
|
238
|
+
}
|
|
239
|
+
if (children.length > 15) {
|
|
240
|
+
lines.push(` ... (${children.length - 15} more)`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
for (const f of files) {
|
|
244
|
+
lines.push(` ${f}`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const contextFile = path.join(cwd, ".aether", "context.md");
|
|
248
|
+
const context = readTextSafe(contextFile, 3000);
|
|
249
|
+
if (context) {
|
|
250
|
+
lines.push("");
|
|
251
|
+
lines.push("project-instructions:");
|
|
252
|
+
lines.push(context.trim());
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const readme = readTextSafe(path.join(cwd, "README.md"), 1500);
|
|
256
|
+
if (readme) {
|
|
257
|
+
lines.push("");
|
|
258
|
+
lines.push("readme-excerpt:");
|
|
259
|
+
lines.push(readme.trim());
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
lines.push("[/project]");
|
|
263
|
+
return lines.join("\n") + "\n";
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function scanProjectQuick(cwd) {
|
|
267
|
+
const { dirs, files } = listTopLevel(cwd);
|
|
268
|
+
const total = dirs.length + files.length;
|
|
269
|
+
if (total === 0) return "empty directory";
|
|
270
|
+
const frameworks = detectFrameworks(cwd, files);
|
|
271
|
+
const pkg = extractPackageInfo(cwd);
|
|
272
|
+
const parts = [];
|
|
273
|
+
if (pkg?.name) parts.push(pkg.name);
|
|
274
|
+
if (frameworks.length > 0) parts.push(frameworks.join(", "));
|
|
275
|
+
else if (pkg?.frameworks?.length) parts.push(pkg.frameworks[0]);
|
|
276
|
+
parts.push(`${total} items`);
|
|
277
|
+
if (pkg?.scripts) parts.push(`${pkg.scripts.length} scripts`);
|
|
278
|
+
return parts.join(" · ");
|
|
279
|
+
}
|