Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: rank Node server entry points above docker/static classification (#4137)

Adam Eivy8c0cfeeff80a
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.js
index ac76864c81..324e0db08c 100644
--- a/server/services/streamingDetect.js
+++ b/server/services/streamingDetect.js
@@ -10,32 +10,43 @@ import { detectAppIcon } from './appIconDetect.js';
export const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swift']);
/**
- * Non-Node runtimes recognized from marker files, mapped to the files that
- * identify them. Order is precedence: a repo's LANGUAGE beats its packaging, so
- * a Python service that also ships a `Dockerfile` classifies as `python` (the
- * common case), while a compose-only stack with no language markers is
- * `docker`. `static` is last — it's the "nothing but a page here" fallback.
+ * Language markers, checked FIRST: a repo's LANGUAGE beats its packaging, so a
+ * Python service that also ships a `Dockerfile` classifies as `python` (the
+ * common case) rather than as a Docker stack.
*/
-const NON_NODE_MARKERS = [
+const LANGUAGE_MARKERS = [
['python', ['pyproject.toml', 'requirements.txt', 'setup.py', 'Pipfile']],
- ['go', ['go.mod']],
- ['docker', ['docker-compose.yml', 'docker-compose.yaml', 'compose.yml', 'compose.yaml', 'Dockerfile']]
+ ['go', ['go.mod']]
];
+/** Compose/Dockerfile markers — only reached when no language marker matched. */
+const DOCKER_MARKERS = ['docker-compose.yml', 'docker-compose.yaml', 'compose.yml', 'compose.yaml', 'Dockerfile'];
+
/**
- * Files meaning "something SERVES this directory". A package-less repo holding
- * one of these is a served app, not a static site, so `static` must not claim
- * it. `index.js` is deliberately absent: next to an `index.html` it is far more
- * often a client-side script than a server entry point.
+ * Node entry points meaning "a process runs here". Checked BEFORE the docker
+ * and static rules, and mapped to *no* classification rather than to a type: a
+ * package-less repo shipping `server.mjs` is a Node app someone containerized
+ * (or that also serves a page), and classifying it `docker`/`static` would
+ * withdraw standardization from an app that genuinely wants it — the exact
+ * false negative this predicate exists to avoid. `index` is deliberately absent
+ * from the basenames: next to an `index.html` it is far more often a
+ * client-side script than a server entry point.
*/
-const SERVER_ENTRY_MARKERS = ['server.js', 'app.js', 'ecosystem.config.js', 'ecosystem.config.cjs'];
+const SERVER_ENTRY_BASENAMES = ['server', 'app', 'main'];
+const SERVER_ENTRY_EXTENSIONS = ['.js', '.mjs', '.cjs', '.ts'];
+
+const hasNodeServerEntry = (present) =>
+ // ECOSYSTEM_CONFIG_FILENAMES (below) is the one list of PM2 config names — a
+ // repo carrying one is unambiguously a PM2-managed process app.
+ ECOSYSTEM_CONFIG_FILENAMES.some(name => present.has(name)) ||
+ SERVER_ENTRY_BASENAMES.some(base => SERVER_ENTRY_EXTENSIONS.some(ext => present.has(`${base}${ext}`)));
/** The non-Node app types `classifyNonNodeType` can emit. */
-export const NON_NODE_TYPES = new Set([...NON_NODE_MARKERS.map(([type]) => type), 'static']);
+export const NON_NODE_TYPES = new Set([...LANGUAGE_MARKERS.map(([type]) => type), 'docker', 'static']);
/**
* Classify a repo's runtime from its top-level filenames, for repos that
- * carried no Node or Apple signal. Returns `null` when no marker matched — the
+ * carried no Node or Apple signal. Returns `null` when nothing matched — the
* caller keeps `unknown` rather than guessing.
*
* @param {string[]} files Top-level entry names (from `readdir`).
@@ -43,16 +54,12 @@ export const NON_NODE_TYPES = new Set([...NON_NODE_MARKERS.map(([type]) => type)
*/
export function classifyNonNodeType(files) {
const present = new Set(files || []);
- for (const [type, markers] of NON_NODE_MARKERS) {
+ for (const [type, markers] of LANGUAGE_MARKERS) {
if (markers.some(marker => present.has(marker))) return type;
}
- // `static` is the last resort and the only rule carrying a negative
- // condition — "an index.html with no server". An index.html sitting beside a
- // server entry point is a served app, so fall through to `unknown` (which
- // stays standardizable) rather than wrongly withdrawing the flow.
- if (present.has('index.html') && !SERVER_ENTRY_MARKERS.some(marker => present.has(marker))) {
- return 'static';
- }
+ if (hasNodeServerEntry(present)) return null;
+ if (DOCKER_MARKERS.some(marker => present.has(marker))) return 'docker';
+ if (present.has('index.html')) return 'static';
return null;
}
diff --git a/server/services/streamingDetect.test.js b/server/services/streamingDetect.test.js
index 60d0063de2..108f61d17e 100644
--- a/server/services/streamingDetect.test.js
+++ b/server/services/streamingDetect.test.js
@@ -1138,22 +1138,40 @@ describe('classifyNonNodeType', () => {
it('does not call an index.html beside a server entry point static', () => {
// "index.html with NO server" is the rule. A served app that happens to
// have an index.html must fall through to `unknown` (still standardizable)
- // rather than have the flow withdrawn from it.
- for (const server of ['server.js', 'app.js', 'ecosystem.config.js', 'ecosystem.config.cjs']) {
+ // rather than have the flow withdrawn from it. Every JS/TS extension counts
+ // — `server.mjs` is as much an entry point as `server.js`.
+ for (const server of [
+ 'server.js', 'server.mjs', 'server.cjs', 'server.ts',
+ 'app.js', 'app.mjs', 'main.js', 'main.ts',
+ 'ecosystem.config.js', 'ecosystem.config.cjs'
+ ]) {
expect(classifyNonNodeType(['index.html', server])).toBeNull();
}
});
+ it('does not call a Node server with a Dockerfile a docker stack', () => {
+ // A containerized Node service is still a Node service — the entry point
+ // outranks the packaging, the same way a language marker does.
+ expect(classifyNonNodeType(['server.js', 'Dockerfile'])).toBeNull();
+ expect(classifyNonNodeType(['app.mjs', 'docker-compose.yml'])).toBeNull();
+ });
+
it('still treats a client-side index.js as static, not a server', () => {
// In a static site an `index.js` is a browser script far more often than a
// server entry point, so it must not suppress the classification.
expect(classifyNonNodeType(['index.html', 'index.js', 'style.css'])).toBe('static');
});
+ it('keeps the language markers ahead of a Node entry point', () => {
+ // A Python repo with a stray `app.py`-adjacent `main.js` build script is
+ // still python — the language check runs first.
+ expect(classifyNonNodeType(['requirements.txt', 'main.js'])).toBe('python');
+ });
+
it('prefers the language over the packaging when both markers are present', () => {
// A Python service that also ships a Dockerfile is a python repo, not a
// docker stack — the language is the more useful classification, and both
- // land outside STANDARDIZABLE_TYPES either way.
+ // are refused by the standardize gate either way.
expect(classifyNonNodeType(['pyproject.toml', 'Dockerfile', 'index.html'])).toBe('python');
expect(classifyNonNodeType(['go.mod', 'docker-compose.yml'])).toBe('go');
expect(classifyNonNodeType(['Dockerfile', 'index.html'])).toBe('docker');