neuron-inspector 0.1.2 → 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.
@@ -0,0 +1,306 @@
1
+ /**
2
+ * Recipe manager — list, read, create, import, export, and log memory
3
+ * for self-improving agent recipes. All file operations are local.
4
+ */
5
+ import * as fs from "node:fs";
6
+ import * as path from "node:path";
7
+ import * as os from "node:os";
8
+ import { execSync } from "node:child_process";
9
+ import YAML from "yaml";
10
+ // ── Paths ───────────────────────────────────────────────────
11
+ /** Bundled recipes shipped with the package */
12
+ function bundledRecipesDir() {
13
+ const srcDir = path.dirname(new URL(import.meta.url).pathname);
14
+ return path.join(srcDir, "..", "recipes");
15
+ }
16
+ /** User's local recipe store */
17
+ function userRecipesDir() {
18
+ const dir = path.join(os.homedir(), ".neuron", "recipes");
19
+ if (!fs.existsSync(dir))
20
+ fs.mkdirSync(dir, { recursive: true });
21
+ return dir;
22
+ }
23
+ /** User profile path */
24
+ function profilePath() {
25
+ return path.join(os.homedir(), ".neuron", "profile.yaml");
26
+ }
27
+ // ── Helpers ─────────────────────────────────────────────────
28
+ function readText(filePath) {
29
+ try {
30
+ return fs.readFileSync(filePath, "utf8");
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
36
+ function parseYaml(text) {
37
+ try {
38
+ const parsed = YAML.parse(text);
39
+ return typeof parsed === "object" && parsed !== null ? parsed : {};
40
+ }
41
+ catch {
42
+ return {};
43
+ }
44
+ }
45
+ function parseRecipe(dir, location) {
46
+ const yamlPath = path.join(dir, "recipe.yaml");
47
+ const yamlText = readText(yamlPath);
48
+ if (!yamlText)
49
+ return null;
50
+ const meta = parseYaml(yamlText);
51
+ const tags = Array.isArray(meta.tags)
52
+ ? meta.tags.map(String)
53
+ : [];
54
+ const memoryDir = path.join(dir, "memory");
55
+ const memoryFiles = fs.existsSync(memoryDir)
56
+ ? fs.readdirSync(memoryDir).filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"))
57
+ : [];
58
+ const learningsPath = path.join(dir, "learnings.md");
59
+ return {
60
+ name: String(meta.name || path.basename(dir)),
61
+ slug: path.basename(dir),
62
+ version: String(meta.version || "0.0.0"),
63
+ description: String(meta.description || ""),
64
+ author: String(meta.author || "unknown"),
65
+ tags,
66
+ location,
67
+ path: dir,
68
+ has_learnings: fs.existsSync(learningsPath) && (readText(learningsPath) ?? "").length > 100,
69
+ has_memory: memoryFiles.length > 0,
70
+ memory_count: memoryFiles.length,
71
+ };
72
+ }
73
+ // ── Resolve recipe directory ────────────────────────────────
74
+ function resolveRecipeDir(slug) {
75
+ const userDir = path.join(userRecipesDir(), slug);
76
+ if (fs.existsSync(userDir))
77
+ return userDir;
78
+ const bundledDir = path.join(bundledRecipesDir(), slug);
79
+ if (fs.existsSync(bundledDir))
80
+ return bundledDir;
81
+ return null;
82
+ }
83
+ /** Fork a bundled recipe to user dir for writing, return the user dir path. */
84
+ function ensureWritable(slug) {
85
+ const userDir = path.join(userRecipesDir(), slug);
86
+ if (fs.existsSync(userDir))
87
+ return userDir;
88
+ const bundledDir = path.join(bundledRecipesDir(), slug);
89
+ if (fs.existsSync(bundledDir)) {
90
+ fs.cpSync(bundledDir, userDir, { recursive: true });
91
+ return userDir;
92
+ }
93
+ throw new Error(`Recipe "${slug}" not found.`);
94
+ }
95
+ // ── Public API ──────────────────────────────────────────────
96
+ export function listRecipes() {
97
+ const recipes = [];
98
+ const bundled = bundledRecipesDir();
99
+ if (fs.existsSync(bundled)) {
100
+ for (const entry of fs.readdirSync(bundled, { withFileTypes: true })) {
101
+ if (!entry.isDirectory())
102
+ continue;
103
+ const r = parseRecipe(path.join(bundled, entry.name), "bundled");
104
+ if (r)
105
+ recipes.push(r);
106
+ }
107
+ }
108
+ const user = userRecipesDir();
109
+ for (const entry of fs.readdirSync(user, { withFileTypes: true })) {
110
+ if (!entry.isDirectory())
111
+ continue;
112
+ const r = parseRecipe(path.join(user, entry.name), "user");
113
+ if (r)
114
+ recipes.push(r);
115
+ }
116
+ return recipes;
117
+ }
118
+ export function getRecipe(slug) {
119
+ const dir = resolveRecipeDir(slug);
120
+ if (!dir)
121
+ return null;
122
+ const location = dir.startsWith(userRecipesDir()) ? "user" : "bundled";
123
+ const meta = parseRecipe(dir, location);
124
+ if (!meta)
125
+ return null;
126
+ const agentMd = readText(path.join(dir, "agent.md")) ?? "";
127
+ const recipeYaml = readText(path.join(dir, "recipe.yaml")) ?? "";
128
+ const learnings = readText(path.join(dir, "learnings.md"));
129
+ const parsed = parseYaml(recipeYaml);
130
+ const variables = parsed.variables ?? {};
131
+ // Merge profile into variables to pre-fill matching keys
132
+ const profile = getProfile();
133
+ const resolved = {};
134
+ for (const [varName, varDef] of Object.entries(variables)) {
135
+ const def = varDef;
136
+ if (profile && varName in profile) {
137
+ resolved[varName] = profile[varName];
138
+ }
139
+ else if (def && "default" in def) {
140
+ resolved[varName] = def.default;
141
+ }
142
+ }
143
+ return {
144
+ meta,
145
+ agent_md: agentMd,
146
+ recipe_yaml: recipeYaml,
147
+ learnings,
148
+ variables,
149
+ profile,
150
+ resolved_variables: resolved,
151
+ };
152
+ }
153
+ export function createRecipe(slug, name, description, agentMd, recipeYaml) {
154
+ const dir = path.join(userRecipesDir(), slug);
155
+ if (fs.existsSync(dir)) {
156
+ throw new Error(`Recipe "${slug}" already exists at ${dir}. Use a different slug or delete the existing one.`);
157
+ }
158
+ fs.mkdirSync(dir, { recursive: true });
159
+ fs.writeFileSync(path.join(dir, "agent.md"), agentMd);
160
+ fs.writeFileSync(path.join(dir, "recipe.yaml"), recipeYaml);
161
+ fs.writeFileSync(path.join(dir, "learnings.md"), `# Learnings\n\nNo runs yet.\n`);
162
+ return { path: dir };
163
+ }
164
+ export function updateRecipe(slug, updates) {
165
+ const dir = ensureWritable(slug);
166
+ if (updates.agent_md)
167
+ fs.writeFileSync(path.join(dir, "agent.md"), updates.agent_md);
168
+ if (updates.learnings)
169
+ fs.writeFileSync(path.join(dir, "learnings.md"), updates.learnings);
170
+ if (updates.recipe_yaml)
171
+ fs.writeFileSync(path.join(dir, "recipe.yaml"), updates.recipe_yaml);
172
+ return { path: dir };
173
+ }
174
+ export function logMemory(slug, entry) {
175
+ const dir = ensureWritable(slug);
176
+ const memDir = path.join(dir, "memory");
177
+ if (!fs.existsSync(memDir))
178
+ fs.mkdirSync(memDir, { recursive: true });
179
+ const now = new Date();
180
+ const ts = now.toISOString().replace(/[:.]/g, "-").slice(0, 19);
181
+ const count = fs.readdirSync(memDir).length + 1;
182
+ const filename = `${ts}-run-${String(count).padStart(3, "0")}.yaml`;
183
+ const filepath = path.join(memDir, filename);
184
+ const data = { date: now.toISOString(), ...entry };
185
+ fs.writeFileSync(filepath, YAML.stringify(data));
186
+ return { path: filepath };
187
+ }
188
+ export function getMemory(slug, limit = 20) {
189
+ const dir = resolveRecipeDir(slug);
190
+ if (!dir)
191
+ throw new Error(`Recipe "${slug}" not found.`);
192
+ const memDir = path.join(dir, "memory");
193
+ if (!fs.existsSync(memDir))
194
+ return { entries: [], total: 0 };
195
+ const files = fs.readdirSync(memDir)
196
+ .filter((f) => f.endsWith(".yaml") || f.endsWith(".yml"))
197
+ .sort()
198
+ .reverse();
199
+ const entries = [];
200
+ for (const f of files.slice(0, limit)) {
201
+ const text = readText(path.join(memDir, f));
202
+ if (text) {
203
+ entries.push({ _file: f, ...parseYaml(text) });
204
+ }
205
+ }
206
+ return { entries, total: files.length };
207
+ }
208
+ export function importRecipe(source) {
209
+ let srcDir;
210
+ if (source.startsWith("github:")) {
211
+ const parts = source.slice(7).split("/");
212
+ const repo = `${parts[0]}/${parts[1]}`;
213
+ const subpath = parts.slice(2).join("/");
214
+ const tmpDir = path.join(os.tmpdir(), `neuron-recipe-${Date.now()}`);
215
+ try {
216
+ execSync(`git clone --depth 1 https://github.com/${repo}.git "${tmpDir}"`, { stdio: "pipe" });
217
+ }
218
+ catch {
219
+ throw new Error(`Failed to clone https://github.com/${repo}`);
220
+ }
221
+ srcDir = subpath ? path.join(tmpDir, subpath) : tmpDir;
222
+ if (!fs.existsSync(path.join(srcDir, "recipe.yaml"))) {
223
+ const recipesSubdir = path.join(srcDir, "recipes");
224
+ if (fs.existsSync(recipesSubdir)) {
225
+ const imported = [];
226
+ for (const entry of fs.readdirSync(recipesSubdir, { withFileTypes: true })) {
227
+ if (!entry.isDirectory())
228
+ continue;
229
+ if (!fs.existsSync(path.join(recipesSubdir, entry.name, "recipe.yaml")))
230
+ continue;
231
+ const destDir = path.join(userRecipesDir(), entry.name);
232
+ if (fs.existsSync(destDir))
233
+ continue;
234
+ fs.cpSync(path.join(recipesSubdir, entry.name), destDir, { recursive: true });
235
+ // Strip memory from imports
236
+ const mem = path.join(destDir, "memory");
237
+ if (fs.existsSync(mem))
238
+ fs.rmSync(mem, { recursive: true, force: true });
239
+ imported.push(entry.name);
240
+ }
241
+ fs.rmSync(tmpDir, { recursive: true, force: true });
242
+ if (imported.length === 0)
243
+ throw new Error("No new recipes found in repository");
244
+ return { slug: imported.join(", "), path: userRecipesDir() };
245
+ }
246
+ fs.rmSync(tmpDir, { recursive: true, force: true });
247
+ throw new Error("No recipe.yaml found in repository root or recipes/ subdirectory");
248
+ }
249
+ }
250
+ else {
251
+ srcDir = path.resolve(source);
252
+ }
253
+ if (!fs.existsSync(path.join(srcDir, "recipe.yaml"))) {
254
+ throw new Error(`No recipe.yaml found at ${srcDir}`);
255
+ }
256
+ const yamlText = readText(path.join(srcDir, "recipe.yaml"));
257
+ const meta = yamlText ? parseYaml(yamlText) : {};
258
+ const slug = String(meta.name || path.basename(srcDir))
259
+ .toLowerCase()
260
+ .replace(/\s+/g, "-")
261
+ .replace(/[^a-z0-9-]/g, "");
262
+ const destDir = path.join(userRecipesDir(), slug);
263
+ if (fs.existsSync(destDir)) {
264
+ throw new Error(`Recipe "${slug}" already exists. Delete it first or use a different name.`);
265
+ }
266
+ fs.cpSync(srcDir, destDir, { recursive: true });
267
+ const importedMemory = path.join(destDir, "memory");
268
+ if (fs.existsSync(importedMemory)) {
269
+ fs.rmSync(importedMemory, { recursive: true, force: true });
270
+ }
271
+ return { slug, path: destDir };
272
+ }
273
+ export function exportRecipe(slug, includeLearnings = true) {
274
+ const recipe = getRecipe(slug);
275
+ if (!recipe)
276
+ throw new Error(`Recipe "${slug}" not found.`);
277
+ return {
278
+ agent_md: recipe.agent_md,
279
+ recipe_yaml: recipe.recipe_yaml,
280
+ learnings: includeLearnings ? recipe.learnings : null,
281
+ };
282
+ }
283
+ export function deleteRecipe(slug) {
284
+ const dir = path.join(userRecipesDir(), slug);
285
+ if (!fs.existsSync(dir)) {
286
+ throw new Error(`Recipe "${slug}" not found in user recipes. Bundled recipes can't be deleted.`);
287
+ }
288
+ fs.rmSync(dir, { recursive: true, force: true });
289
+ }
290
+ export function getProfile() {
291
+ const text = readText(profilePath());
292
+ if (!text)
293
+ return null;
294
+ return parseYaml(text);
295
+ }
296
+ export function saveProfile(data) {
297
+ const dir = path.dirname(profilePath());
298
+ if (!fs.existsSync(dir))
299
+ fs.mkdirSync(dir, { recursive: true });
300
+ // Merge with existing profile
301
+ const existing = getProfile() ?? {};
302
+ const merged = { ...existing, ...data };
303
+ fs.writeFileSync(profilePath(), YAML.stringify(merged));
304
+ return { path: profilePath() };
305
+ }
306
+ //# sourceMappingURL=recipes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipes.js","sourceRoot":"","sources":["../src/recipes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,+DAA+D;AAE/D,+CAA+C;AAC/C,SAAS,iBAAiB;IACxB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,CA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EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhE,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,UAAU,EAAE,IAAI,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC;IACxC,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAAC;AACjC,CAAC"}
package/dist/server.js CHANGED
@@ -3,6 +3,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
3
3
  import { WebSocketServer, WebSocket } from "ws";
4
4
  import { PendingCalls } from "./correlation.js";
5
5
  import { TOOLS, toolToPrimitive } from "./tools.js";
6
+ import { RECIPE_TOOLS, handleRecipeTool } from "./recipe-tools.js";
6
7
  const PORT = parseInt(process.env.NEURON_BRIDGE_PORT ?? "7377", 10);
7
8
  // ── State ────────────────────────────────────────────────────
8
9
  let extensionWs = null;
@@ -38,9 +39,9 @@ console.error(`[bridge] WebSocket server listening on 127.0.0.1:${PORT}`);
38
39
  // ── MCP server (Claude Code / Cursor connects via stdio) ────
39
40
  const mcp = new McpServer({
40
41
  name: "neuron-inspector",
41
- version: "0.1.2",
42
+ version: "0.2.0",
42
43
  });
43
- // Register all tools
44
+ // Browser tools (forwarded to extension via WebSocket)
44
45
  for (const tool of TOOLS) {
45
46
  mcp.tool(tool.name, tool.description, tool.inputSchema, async (args) => {
46
47
  if (!extensionWs || extensionWs.readyState !== WebSocket.OPEN) {
@@ -64,11 +65,26 @@ for (const tool of TOOLS) {
64
65
  }
65
66
  });
66
67
  }
68
+ // Recipe tools (local, no extension needed)
69
+ for (const tool of RECIPE_TOOLS) {
70
+ mcp.tool(tool.name, tool.description, tool.inputSchema, async (args) => {
71
+ try {
72
+ const result = await handleRecipeTool(tool.name, args);
73
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
74
+ }
75
+ catch (err) {
76
+ return {
77
+ content: [{ type: "text", text: `Error: ${err.message}` }],
78
+ isError: true,
79
+ };
80
+ }
81
+ });
82
+ }
67
83
  // ── Start ────────────────────────────────────────────────────
68
84
  async function main() {
69
85
  const transport = new StdioServerTransport();
70
86
  await mcp.connect(transport);
71
- console.error("[bridge] MCP server ready on stdio");
87
+ console.error(`[bridge] MCP server ready on stdio (${TOOLS.length} browser + ${RECIPE_TOOLS.length} recipe tools)`);
72
88
  }
73
89
  main().catch((err) => {
74
90
  console.error("[bridge] Fatal:", err);
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;AAEpE,gEAAgE;AAEhE,IAAI,WAAW,GAAqB,IAAI,CAAC;AACzC,MAAM,OAAO,GAAG,IAAI,YAAY,EAAE,CAAC;AAEnC,+DAA+D;AAE/D,MAAM,GAAG,GAAG,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAEnE,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE;IAC1B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC9C,WAAW,GAAG,EAAE,CAAC;IAEjB,EAAE,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OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "neuron-inspector",
3
- "version": "0.1.2",
4
- "description": "51 browser tools for AI agents. Turn Chrome into an MCP server — inspect DOM, automate clicks, audit security, mock APIs, extract data, record demos.",
3
+ "version": "0.2.1",
4
+ "description": "64 tools for AI agents. Turn Chrome into an MCP server — inspect DOM, automate clicks, audit security, mock APIs, extract data, record demos, self-improving recipes.",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",
7
7
  "bin": {
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "files": [
11
11
  "dist/**",
12
- "bin/**"
12
+ "bin/**",
13
+ "recipes/**"
13
14
  ],
14
15
  "scripts": {
15
16
  "build": "tsc",
@@ -47,7 +48,8 @@
47
48
  ],
48
49
  "dependencies": {
49
50
  "@modelcontextprotocol/sdk": "^1.0.0",
50
- "ws": "^8.18.0"
51
+ "ws": "^8.18.0",
52
+ "yaml": "^2.9.0"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@types/node": "^22.0.0",
@@ -0,0 +1,142 @@
1
+ # Job Applicant
2
+
3
+ You are a job application agent. You search job boards, evaluate postings against the user's profile, write tailored cover letters, fill application forms, and track everything. You learn which approaches get responses and which don't.
4
+
5
+ ## Strategy
6
+
7
+ ### Phase 0: Load context
8
+
9
+ Before anything:
10
+ 1. Read the resume at `{{resume_path}}` and extract: skills, experience years, past companies, education, notable projects
11
+ 2. Read `learnings.md` for accumulated intelligence on what's working
12
+ 3. If `{{input.company_research}}` exists, read it for company-specific context
13
+ 4. Read `{{output_path}}/applications.yaml` to know what's already been applied to (never re-apply)
14
+
15
+ ### Phase 1: Find postings
16
+
17
+ Search {{job_boards}} for `{{target_roles}}` in `{{locations}}`.
18
+
19
+ 1. `neuron_navigate` to the job board
20
+ 2. `neuron_find_elements` for the search box → `neuron_type` the role query
21
+ 3. If location filter exists, set it
22
+ 4. `neuron_extract_data` on the results — pull: title, company, location, posted date, URL
23
+ 5. `neuron_scroll` to load more results if the page lazy-loads
24
+
25
+ Filter out:
26
+ - Already applied (check applications.yaml)
27
+ - Locations that don't match `{{locations}}`
28
+ - Any posting that contains `{{deal_breakers}}`
29
+
30
+ Score remaining postings 1-5 on fit based on: skills match, seniority match, company type, posted recency.
31
+
32
+ ### Phase 2: Evaluate
33
+
34
+ For each posting scored 3+, open it and deep-read:
35
+
36
+ 1. `neuron_navigate` to the posting URL
37
+ 2. `neuron_extract_data` to pull the full job description
38
+ 3. Score the match in detail:
39
+ - Skills match: what % of required skills does the resume cover?
40
+ - Seniority match: is the level right?
41
+ - Red flags: any of `{{deal_breakers}}`?
42
+ - Salary: if posted, does it meet `{{salary_min}}`?
43
+
44
+ If the match score is 3+ and there are no red flags, proceed to Phase 3.
45
+
46
+ ### Phase 3: Write cover letter
47
+
48
+ For each qualified posting, generate a tailored cover letter:
49
+
50
+ 1. **Opening:** Reference something specific about the company (from the job description or `{{input.company_research}}` if available). Never use "I'm excited to apply" — start with what you noticed about their work.
51
+ 2. **Match:** Connect 2-3 specific resume items to their requirements. Use concrete examples, not adjectives.
52
+ 3. **Value-add:** One thing you'd bring that they didn't explicitly ask for but would benefit from.
53
+ 4. **Close:** Specific, short, no desperation.
54
+
55
+ Tone: `{{cover_letter_tone}}`
56
+
57
+ Save the cover letter to `{{output_path}}/covers/{{company_slug}}-{{date}}.md`.
58
+
59
+ Check `learnings.md` for what's worked before. If formal openings get more responses than casual ones, adjust. If mentioning specific projects gets callbacks, do more of that.
60
+
61
+ ### Phase 4: Apply
62
+
63
+ Navigate to the application form:
64
+
65
+ 1. `neuron_find_elements` to map the form fields
66
+ 2. `neuron_type` to fill standard fields (name, email, phone, LinkedIn from profile)
67
+ 3. For resume upload: `neuron_find_elements` for file input, flag for human if needed
68
+ 4. For cover letter fields: paste the generated cover letter
69
+ 5. For custom questions: answer based on resume context — be specific, not generic
70
+
71
+ Before submission:
72
+ 1. `neuron_screenshot` the filled form
73
+ 2. If `{{auto_submit}}` is "review": stop and ask the user to review
74
+ 3. If "auto": `neuron_click` the submit button, then `neuron_screenshot` the confirmation
75
+
76
+ ### Phase 5: Record
77
+
78
+ Log the application:
79
+
80
+ ```yaml
81
+ - date: {{now}}
82
+ company: "<company name>"
83
+ role: "<role title>"
84
+ url: "<posting URL>"
85
+ match_score: <1-5>
86
+ cover_letter: "<path to cover letter file>"
87
+ status: submitted
88
+ response: pending
89
+ notes: "<anything notable about this application>"
90
+ ```
91
+
92
+ Append to `{{output_path}}/applications.yaml`.
93
+
94
+ ## Reflect
95
+
96
+ After each run, create a memory entry:
97
+
98
+ ```yaml
99
+ date: {{now}}
100
+ outcome:
101
+ postings_found: <count>
102
+ postings_qualified: <count scoring 3+>
103
+ applications_submitted: <count>
104
+ cover_letter_approach: "<what style/angle was used>"
105
+ form_fill_issues:
106
+ - "<any form that was tricky and why>"
107
+ time_per_application_minutes: <average>
108
+ boards_searched:
109
+ - board: "<name>"
110
+ results_quality: <1-5>
111
+ ```
112
+
113
+ ### Tracking responses (manual)
114
+
115
+ When a response comes back (interview invite, rejection, silence after 2 weeks), update the application entry's `status` and `response` fields. The evolve phase uses this data.
116
+
117
+ ## Evolve
118
+
119
+ After 10+ applications with at least 3 response outcomes, review memory and update `learnings.md`:
120
+
121
+ **Cover letter strategy:**
122
+ - Which openings get responses? Compare formal vs conversational vs technical.
123
+ - Does mentioning specific projects/numbers help?
124
+ - Does company-specific research in the opening correlate with callbacks?
125
+ - What length works? Short (3 para) vs detailed (5+ para)?
126
+
127
+ **Board quality:**
128
+ - Which boards have the most relevant postings?
129
+ - Which boards have the freshest postings (not stale 30+ day old)?
130
+ - Which boards' application forms are easiest to fill programmatically?
131
+
132
+ **Match scoring:**
133
+ - Are the 3+ scored postings actually converting to interviews?
134
+ - Should the scoring weights change? (e.g., skills match matters more than seniority match)
135
+
136
+ **Form filling:**
137
+ - Are there common custom questions that should have pre-written answers?
138
+ - Which form patterns are consistently tricky?
139
+
140
+ Update learnings, then update Strategy. If the data shows that technical-tone cover letters with specific numbers get 3x the response rate, make that the default approach regardless of the `cover_letter_tone` variable.
141
+
142
+ The goal is not more applications. It's more *responses per application*.
@@ -0,0 +1,15 @@
1
+ # Learnings
2
+
3
+ No applications submitted yet. This file updates after 10+ applications with response data.
4
+
5
+ ## Cover Letter Defaults
6
+
7
+ Starting assumptions (to be validated):
8
+ - Lead with something specific about the company, never "I'm excited to apply"
9
+ - Mention 2-3 concrete examples from past work, not adjectives
10
+ - Keep to 3-4 paragraphs
11
+ - Close with a specific ask, not "I look forward to hearing from you"
12
+
13
+ ## Board Notes
14
+
15
+ No data yet. Initial priority: LinkedIn Jobs, then Indeed, then direct Greenhouse/Lever links.
@@ -0,0 +1,87 @@
1
+ name: Job Applicant
2
+ version: 1.0.0
3
+ description: >
4
+ Navigates job boards, reads postings, matches them against your profile,
5
+ tailors cover letters, fills application forms, and tracks submissions.
6
+ Learns which approaches get responses and adjusts over time.
7
+ author: neuron
8
+ tags: [jobs, applications, career, automation]
9
+
10
+ variables:
11
+ resume_path:
12
+ prompt: "Path to your resume (PDF, MD, or TXT)"
13
+ type: path
14
+ required: true
15
+ target_roles:
16
+ prompt: "Roles you're targeting (comma-separated)"
17
+ type: text
18
+ required: true
19
+ example: "Senior Backend Engineer, Platform Engineer, Staff Engineer"
20
+ locations:
21
+ prompt: "Preferred locations (comma-separated, or 'remote')"
22
+ type: text
23
+ default: "remote"
24
+ salary_min:
25
+ prompt: "Minimum salary (number, or leave blank)"
26
+ type: text
27
+ default: ""
28
+ deal_breakers:
29
+ prompt: "Automatic disqualifiers (comma-separated)"
30
+ type: text
31
+ default: ""
32
+ example: "no equity, requires clearance, unpaid trial"
33
+ cover_letter_tone:
34
+ prompt: "Cover letter tone"
35
+ options: [professional, conversational, technical]
36
+ default: professional
37
+ job_boards:
38
+ prompt: "Job boards to search"
39
+ default: "linkedin.com/jobs, indeed.com, greenhouse.io, lever.co"
40
+ output_path:
41
+ prompt: "Where to save application records"
42
+ type: path
43
+ default: "./applications"
44
+ auto_submit:
45
+ prompt: "Auto-submit applications, or pause for review?"
46
+ options: [auto, review]
47
+ default: review
48
+
49
+ tools:
50
+ required:
51
+ - neuron_navigate
52
+ - neuron_extract_data
53
+ - neuron_find_elements
54
+ - neuron_type
55
+ - neuron_click
56
+ - neuron_scroll
57
+ - neuron_screenshot
58
+ - neuron_list_tabs
59
+ optional:
60
+ - neuron_evaluate_js
61
+ - neuron_open_tab
62
+ - neuron_search_traffic
63
+ - neuron_detect_blocker
64
+ - neuron_snapshot_state
65
+ - neuron_diff_states
66
+
67
+ pipes:
68
+ outputs:
69
+ applications_log:
70
+ format: yaml
71
+ path: "{{output_path}}/applications.yaml"
72
+ description: "Running log of all applications submitted"
73
+ cover_letters:
74
+ format: markdown
75
+ path: "{{output_path}}/covers/{{company_slug}}-{{date}}.md"
76
+ description: "Generated cover letters for review and reuse"
77
+ inputs:
78
+ company_research:
79
+ from: web-researcher
80
+ output: report
81
+ description: "Research on target company — used to tailor cover letters and anticipate interview questions"
82
+ optional: true
83
+
84
+ limits:
85
+ max_tabs: 5
86
+ max_duration_minutes: 60
87
+ require_human_approval: true