@tspappsen/elamax 1.2.3

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/dist/update.js ADDED
@@ -0,0 +1,72 @@
1
+ import { readFileSync } from "fs";
2
+ import { join, dirname } from "path";
3
+ import { fileURLToPath } from "url";
4
+ import { exec as execCb, execSync } from "child_process";
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ function getLocalVersion() {
7
+ try {
8
+ const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
9
+ return pkg.version || "0.0.0";
10
+ }
11
+ catch {
12
+ return "0.0.0";
13
+ }
14
+ }
15
+ /** Run a command asynchronously and return stdout. */
16
+ function execAsync(cmd, timeoutMs) {
17
+ return new Promise((resolve, reject) => {
18
+ execCb(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
19
+ if (err)
20
+ return reject(err);
21
+ resolve(stdout.trim());
22
+ });
23
+ });
24
+ }
25
+ /** Fetch the latest published version from npm. Returns null on failure. */
26
+ export async function getLatestVersion() {
27
+ try {
28
+ const result = await execAsync("npm view elamax version", 10_000);
29
+ return result || null;
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ }
35
+ /** Compare two semver strings. Returns true if remote is newer. */
36
+ function isNewer(local, remote) {
37
+ const parse = (v) => v.split(".").map(Number);
38
+ const [lMaj, lMin, lPat] = parse(local);
39
+ const [rMaj, rMin, rPat] = parse(remote);
40
+ if (rMaj !== lMaj)
41
+ return rMaj > lMaj;
42
+ if (rMin !== lMin)
43
+ return rMin > lMin;
44
+ return rPat > lPat;
45
+ }
46
+ /** Check whether a newer version is available on npm. */
47
+ export async function checkForUpdate() {
48
+ const current = getLocalVersion();
49
+ const latest = await getLatestVersion();
50
+ return {
51
+ current,
52
+ latest,
53
+ updateAvailable: latest !== null && isNewer(current, latest),
54
+ checkSucceeded: latest !== null,
55
+ };
56
+ }
57
+ /** Run `npm install -g elamax@latest` and return success/failure. */
58
+ export async function performUpdate() {
59
+ try {
60
+ const output = execSync("npm install -g elamax@latest", {
61
+ encoding: "utf-8",
62
+ timeout: 60_000,
63
+ stdio: ["ignore", "pipe", "pipe"],
64
+ });
65
+ return { ok: true, output: output.trim() };
66
+ }
67
+ catch (err) {
68
+ const msg = err.stderr?.trim() || err.message || "Unknown error";
69
+ return { ok: false, output: msg };
70
+ }
71
+ }
72
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1,71 @@
1
+ /**
2
+ * 3-tier JSON parsing utility for LLM output.
3
+ *
4
+ * Tier 1 — Direct parse: try JSON.parse(input) as-is.
5
+ * Tier 2 — Markdown fence extraction: strip ```json ... ``` (or plain ```) fences, then parse.
6
+ * Tier 3 — Balanced brace matching: scan for the first `{` or `[`, find its matching
7
+ * closing bracket, extract that substring, and parse.
8
+ *
9
+ * Returns the parsed value or `null` if all tiers fail.
10
+ */
11
+ export function parseJSON(input) {
12
+ const text = input.trim();
13
+ // Tier 1: direct parse
14
+ try {
15
+ return JSON.parse(text);
16
+ }
17
+ catch {
18
+ // fall through
19
+ }
20
+ // Tier 2: markdown fence extraction
21
+ const fenceMatch = text.match(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/i);
22
+ if (fenceMatch) {
23
+ try {
24
+ return JSON.parse(fenceMatch[1].trim());
25
+ }
26
+ catch {
27
+ // fall through
28
+ }
29
+ }
30
+ // Tier 3: balanced brace/bracket matching
31
+ const start = text.search(/[{[]/);
32
+ if (start !== -1) {
33
+ const open = text[start];
34
+ const close = open === "{" ? "}" : "]";
35
+ let depth = 0;
36
+ let inString = false;
37
+ let escape = false;
38
+ for (let i = start; i < text.length; i++) {
39
+ const ch = text[i];
40
+ if (escape) {
41
+ escape = false;
42
+ continue;
43
+ }
44
+ if (ch === "\\" && inString) {
45
+ escape = true;
46
+ continue;
47
+ }
48
+ if (ch === '"') {
49
+ inString = !inString;
50
+ continue;
51
+ }
52
+ if (inString)
53
+ continue;
54
+ if (ch === open)
55
+ depth++;
56
+ else if (ch === close) {
57
+ depth--;
58
+ if (depth === 0) {
59
+ try {
60
+ return JSON.parse(text.slice(start, i + 1));
61
+ }
62
+ catch {
63
+ break;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+ //# sourceMappingURL=parseJSON.js.map
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@tspappsen/elamax",
3
+ "version": "1.2.3",
4
+ "description": "Max — a personal AI assistant for developers, built on the GitHub Copilot SDK",
5
+ "bin": {
6
+ "max": "dist/cli.js"
7
+ },
8
+ "files": [
9
+ "dist/**/*.js",
10
+ "skills/",
11
+ "templates/",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "daemon": "tsx src/daemon.ts",
17
+ "tui": "tsx src/tui/index.ts",
18
+ "dev": "tsx --watch-path src src/daemon.ts",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "keywords": [
25
+ "copilot",
26
+ "telegram",
27
+ "orchestrator",
28
+ "ai",
29
+ "cli"
30
+ ],
31
+ "author": "Erik",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/lauraeus/max-assistant"
36
+ },
37
+ "homepage": "https://github.com/lauraeus/max-assistant",
38
+ "bugs": {
39
+ "url": "https://github.com/lauraeus/max-assistant/max/issues"
40
+ },
41
+ "type": "module",
42
+ "dependencies": {
43
+ "@github/copilot-sdk": "0.1.30",
44
+ "better-sqlite3": "^12.6.2",
45
+ "discord.js": "^14.16.3",
46
+ "dotenv": "^17.3.1",
47
+ "express": "^5.2.1",
48
+ "grammy": "^1.40.0",
49
+ "zod": "^4.3.6"
50
+ },
51
+ "devDependencies": {
52
+ "@types/better-sqlite3": "^7.6.13",
53
+ "@types/express": "^5.0.6",
54
+ "@types/node": "^25.3.0",
55
+ "tsx": "^4.21.0",
56
+ "typescript": "^5.9.3"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public"
60
+ }
61
+ }
File without changes
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: find-skills
3
+ description: Helps users discover agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. Always ask the user for permission before installing any skill, and flag security risks.
4
+ ---
5
+
6
+ # Find Skills
7
+
8
+ Discover and install skills from the open agent skills ecosystem at https://skills.sh/.
9
+
10
+ ## When to Use
11
+
12
+ Use this skill when the user:
13
+
14
+ - Asks "how do I do X" where X might be a common task with an existing skill
15
+ - Says "find a skill for X" or "is there a skill for X"
16
+ - Asks "can you do X" where X is a specialized capability
17
+ - Expresses interest in extending agent capabilities
18
+ - Wants to search for tools, templates, or workflows
19
+
20
+ ## Search & Present
21
+
22
+ Do these two steps in a worker session — they can run in parallel:
23
+
24
+ ### 1. Search the API
25
+
26
+ ```bash
27
+ curl -s "https://skills.sh/api/search?q=QUERY"
28
+ ```
29
+
30
+ Replace `QUERY` with a URL-encoded search term (e.g., `react`, `email`, `pr+review`). The response is JSON with skills sorted by installs (most popular first):
31
+
32
+ ```json
33
+ {
34
+ "skills": [
35
+ {
36
+ "id": "vercel-labs/agent-skills/vercel-react-best-practices",
37
+ "skillId": "vercel-react-best-practices",
38
+ "name": "vercel-react-best-practices",
39
+ "installs": 174847,
40
+ "source": "vercel-labs/agent-skills"
41
+ }
42
+ ]
43
+ }
44
+ ```
45
+
46
+ ### 2. Fetch Security Audits
47
+
48
+ **Required — do not skip.** Use the `web_fetch` tool to get the audits page:
49
+
50
+ ```
51
+ web_fetch url="https://skills.sh/audits"
52
+ ```
53
+
54
+ If `web_fetch` fails or returns unexpected content, still present the search results but show "⚠️ Audit unavailable" for all security columns and include a link to https://skills.sh/audits so the user can check manually.
55
+
56
+ This returns markdown where each skill has a heading (`### skill-name`) followed by its source, then three security scores:
57
+
58
+ - **Gen Agent Trust Hub**: Safe / Med Risk / Critical
59
+ - **Socket**: Number of alerts (0 is best)
60
+ - **Snyk**: Low Risk / Med Risk / High Risk / Critical
61
+
62
+ Scan the returned markdown to find scores for each skill from your search results. Match by both **skill name** and **full source** (`owner/repo`) to avoid misattribution — different repos can have skills with the same name.
63
+
64
+ ### 3. Present Combined Results
65
+
66
+ Cross-reference the search results with the audit data and format as a numbered table. Show the top 6-8 results sorted by installs:
67
+
68
+ ```
69
+ # Skill Publisher Installs Gen Socket Snyk
70
+ ─ ───────────────────────────── ───────────── ──────── ───── ────── ────────
71
+ 1 vercel-react-best-practices vercel-labs 175.3K ✅Safe ✅ 0 ✅Low
72
+ 2 web-design-guidelines vercel-labs 135.8K ✅Safe ✅ 0 ⚠️Med
73
+ 3 frontend-design anthropics 122.6K ✅Safe ✅ 0 ✅Low
74
+ 4 remotion-best-practices remotion-dev 125.2K ✅Safe ✅ 0 ⚠️Med
75
+ 5 browser-use browser-use 45.0K ⚠️Med 🔴 1 🔴High
76
+ ```
77
+
78
+ **Formatting:**
79
+ - Sort by installs descending
80
+ - Format counts: 1000+ → "1.0K", 1000000+ → "1.0M"
81
+ - ✅ for Safe / Low Risk / 0 alerts, ⚠️ for Med Risk, 🔴 for High Risk / Critical / 1+ alerts
82
+ - If a skill has no audit data, show "⚠️ N/A" — never leave security blank
83
+ - Publisher = first part of `source` field (before `/`)
84
+
85
+ After the table:
86
+
87
+ ```
88
+ 🔗 Browse all: https://skills.sh/
89
+
90
+ Pick a number to install (or "none")
91
+ ```
92
+
93
+ ## Install
94
+
95
+ **NEVER install without the user picking a number first.**
96
+
97
+ When the user picks a skill:
98
+
99
+ ### Security Gate
100
+
101
+ If ANY of its three audit scores is not green (Safe / 0 alerts / Low Risk), warn before proceeding:
102
+
103
+ ```
104
+ ⚠️ "{skill-name}" has security concerns:
105
+ • Gen Agent Trust Hub: {score}
106
+ • Socket: {count} alerts
107
+ • Snyk: {score}
108
+
109
+ Want to proceed anyway, or pick a different skill?
110
+ ```
111
+
112
+ Wait for explicit confirmation. Do not install if the user says no.
113
+
114
+ ### Fetch & Install
115
+
116
+ 1. **Fetch the SKILL.md** from GitHub. The `source` field is `owner/repo` and `skillId` is the directory:
117
+
118
+ ```bash
119
+ curl -fsSL "https://raw.githubusercontent.com/{source}/main/{skillId}/SKILL.md" || \
120
+ curl -fsSL "https://raw.githubusercontent.com/{source}/master/{skillId}/SKILL.md"
121
+ ```
122
+
123
+ If both fail, tell the user and link to `https://github.com/{source}`.
124
+
125
+ 2. **Validate** the fetched content: it must not be empty and should contain meaningful instructions (more than just a title). If the content is empty, an HTML error page, or clearly not a SKILL.md, do NOT install — tell the user it couldn't be fetched properly.
126
+
127
+ 3. **Install** using the `learn_skill` tool:
128
+ - `slug`: the `skillId` from the API
129
+ - `name`: from the SKILL.md frontmatter `name:` field (between `---` markers). If no frontmatter, use `skillId`.
130
+ - `description`: from the SKILL.md frontmatter `description:` field. If none, use the first sentence.
131
+ - `instructions`: if frontmatter exists, use the content after the closing `---`. If no frontmatter, use the full fetched content as instructions.
132
+
133
+ **Always install to ~/.max/skills/ via learn_skill. Never install globally.**
134
+
135
+ ## Behavioral Security Review
136
+
137
+ In addition to audit scores, review the fetched SKILL.md content before installing. Flag concerns if the skill:
138
+
139
+ - **Runs arbitrary shell commands** or executes code on the user's machine
140
+ - **Accesses sensitive data** — credentials, API keys, SSH keys, personal files
141
+ - **Makes network requests** to external services (data exfiltration risk)
142
+ - **Comes from an unknown or unverified source** with no audit data
143
+
144
+ If any of these apply, warn the user with specifics even if audit scores are green:
145
+
146
+ ```
147
+ ⚠️ Note: "{skill-name}" requests shell access and reads files from your home directory.
148
+ This is common for CLI-integration skills, but worth knowing. Proceed?
149
+ ```
150
+
151
+ ## When No Skills Are Found
152
+
153
+ If the API returns no results:
154
+
155
+ 1. Tell the user no existing skill was found
156
+ 2. Offer to help directly with your general capabilities
157
+ 3. Suggest building a custom skill if the task is worth automating
158
+
159
+ ## Uninstalling
160
+
161
+ Use the `uninstall_skill` tool with the skill's slug to remove it from `~/.max/skills/`.
@@ -0,0 +1,4 @@
1
+ {
2
+ "slug": "find-skills",
3
+ "version": "1.0.0"
4
+ }
@@ -0,0 +1,18 @@
1
+ # Agents
2
+
3
+ You are Max, Eriks Chief of Staff. This folder is home. Treat it that way.
4
+
5
+ ## GitHub Repository Analysis
6
+
7
+ If the user provides a GitHub repository URL:
8
+
9
+ 1. **Analyze** — Use the github-repository-analysis skill/workflow to clone and analyze the github repository. Don't just summarize the README.
10
+ 2. **Post to Discord** — Send your review to the discord channel (see `TOOLS.md` for channel ID). This is required for every analysis.
11
+
12
+ ## X/Twitter Thread Analysis
13
+
14
+ If the user provides an X/Twitter URL, prefer the twitter skill/workflow to fetch the full thread and analyze it.
15
+
16
+ ## Customization
17
+
18
+ Edit this file to customize how Max behaves. Changes are picked up automatically — no restart needed.
@@ -0,0 +1,12 @@
1
+ # Tools
2
+
3
+ ## Discord
4
+
5
+ | Name | Channel ID |
6
+ |---|---|
7
+ | #mac-max | `1486806366508023818` |
8
+
9
+ **Send to Discord:**
10
+ ```
11
+ message action=send channel=discord target="1486806366508023818" message="YOUR_MESSAGE_HERE"
12
+ ```