Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e0eb4eec6 | |||
| cf2b0ac223 | |||
| 1b5a52ea4d | |||
| a084205b47 | |||
| 57550ccfdb | |||
| 37588df402 |
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^1.9.0",
|
"@biomejs/biome": "^1.9.0",
|
||||||
"tsup": "^8.0.0",
|
"@rslib/core": "^0.21.3",
|
||||||
"typescript": "^5.5.0"
|
"typescript": "^5.5.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
|
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
|
||||||
"build": "tsup",
|
"build": "rslib build",
|
||||||
"test": "vitest run"
|
"test": "vitest run"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
"citty": "^0.1.6"
|
"citty": "^0.1.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@rslib/core": "^0.21.3",
|
||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
"@uncaged/nerve-daemon": "workspace:*",
|
"@uncaged/nerve-daemon": "workspace:*",
|
||||||
"vitest": "^4.1.5"
|
"vitest": "^4.1.5"
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { defineConfig } from "@rslib/core";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
lib: [
|
||||||
|
{
|
||||||
|
format: "esm",
|
||||||
|
dts: true,
|
||||||
|
banner: {
|
||||||
|
js: "#!/usr/bin/env node",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
source: {
|
||||||
|
entry: {
|
||||||
|
index: "src/index.ts",
|
||||||
|
cli: "src/cli.ts",
|
||||||
|
"daemon-bootstrap": "src/daemon-bootstrap.ts",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
target: "node",
|
||||||
|
cleanDistPath: true,
|
||||||
|
externals: ["@uncaged/nerve-daemon"],
|
||||||
|
},
|
||||||
|
});
|
||||||
+21
-1
@@ -12,6 +12,26 @@ import { storeCommand } from "./commands/store.js";
|
|||||||
import { validateCommand } from "./commands/validate.js";
|
import { validateCommand } from "./commands/validate.js";
|
||||||
import { workflowCommand } from "./commands/workflow.js";
|
import { workflowCommand } from "./commands/workflow.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Citty picks the first non-flag token as a subcommand name. Rewrite
|
||||||
|
* `nerve init --from <url>` so the URL is not mistaken for `workflow`/`workspace`.
|
||||||
|
*/
|
||||||
|
function normalizeNerveArgv(argv: string[]): string[] {
|
||||||
|
const initIdx = argv.indexOf("init");
|
||||||
|
if (initIdx === -1) return argv;
|
||||||
|
const tail = argv.slice(initIdx + 1);
|
||||||
|
const fromAt = tail.indexOf("--from");
|
||||||
|
if (fromAt === -1) return argv;
|
||||||
|
const beforeFrom = tail.slice(0, fromAt);
|
||||||
|
if (beforeFrom.some((a) => !a.startsWith("-"))) return argv;
|
||||||
|
const next = tail[fromAt + 1];
|
||||||
|
if (next === undefined || next.startsWith("-")) return argv;
|
||||||
|
const reserved = new Set(["workflow", "workspace"]);
|
||||||
|
if (reserved.has(next)) return argv;
|
||||||
|
const mergedTail = [...tail.slice(0, fromAt), `--from=${next}`, ...tail.slice(fromAt + 2)];
|
||||||
|
return [...argv.slice(0, initIdx + 1), ...mergedTail];
|
||||||
|
}
|
||||||
|
|
||||||
const main = defineCommand({
|
const main = defineCommand({
|
||||||
meta: {
|
meta: {
|
||||||
name: "nerve",
|
name: "nerve",
|
||||||
@@ -32,4 +52,4 @@ const main = defineCommand({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
runMain(main);
|
runMain(main, { rawArgs: normalizeNerveArgv(process.argv.slice(2)) });
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { execFile, spawn } from "node:child_process";
|
import { execFile, spawn } from "node:child_process";
|
||||||
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
||||||
import { dirname, join } from "node:path";
|
import { dirname, join } from "node:path";
|
||||||
import { promisify } from "node:util";
|
import { promisify } from "node:util";
|
||||||
|
|
||||||
@@ -236,6 +236,76 @@ async function verifyNodeSqlite(): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isNerveRootNonEmpty(nerveRoot: string): boolean {
|
||||||
|
if (!existsSync(nerveRoot)) return false;
|
||||||
|
return readdirSync(nerveRoot).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runInitFromGit(url: string): Promise<void> {
|
||||||
|
const trimmed = url.trim();
|
||||||
|
if (trimmed.length === 0) {
|
||||||
|
process.stderr.write("❌ --from requires a non-empty git URL.\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const nerveRoot = getNerveRoot();
|
||||||
|
if (isNerveRootNonEmpty(nerveRoot)) {
|
||||||
|
process.stderr.write(
|
||||||
|
`❌ ${nerveRoot} already exists and is not empty. Remove it (or empty it) before using --from.\n`,
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await execFileAsync("git", ["--version"]);
|
||||||
|
} catch {
|
||||||
|
process.stderr.write("❌ git is not available. Install git and retry.\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await execFileAsync("pnpm", ["--version"]);
|
||||||
|
} catch {
|
||||||
|
process.stderr.write("❌ pnpm is not available. Install pnpm and retry.\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.stdout.write(`Cloning ${trimmed} → ${nerveRoot} …\n`);
|
||||||
|
try {
|
||||||
|
await runCommand("git", ["clone", trimmed, nerveRoot], process.cwd());
|
||||||
|
} catch {
|
||||||
|
process.stderr.write("❌ git clone failed.\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existsSync(join(nerveRoot, "nerve.yaml"))) {
|
||||||
|
process.stdout.write(`⚠️ ${join(nerveRoot, "nerve.yaml")} not found after clone.\n`);
|
||||||
|
}
|
||||||
|
if (!existsSync(join(nerveRoot, "package.json"))) {
|
||||||
|
process.stdout.write(`⚠️ ${join(nerveRoot, "package.json")} not found after clone.\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.stdout.write("Installing dependencies with pnpm …\n");
|
||||||
|
try {
|
||||||
|
await runCommand("pnpm", ["install", "--no-cache"], nerveRoot);
|
||||||
|
} catch {
|
||||||
|
process.stdout.write(
|
||||||
|
`⚠️ pnpm install failed. Try manually:\n cd ${nerveRoot} && pnpm install --no-cache\n`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(await verifyNodeSqlite())) {
|
||||||
|
process.stdout.write(
|
||||||
|
"⚠️ Built-in SQLite (node:sqlite) is not available in this Node.js build. " +
|
||||||
|
"The daemon requires Node.js 22.5 or newer with SQLite enabled.\n",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.stdout.write(
|
||||||
|
`✅ Workspace cloned to ${nerveRoot}\n\n💡 Next steps:\n 1. Review nerve.yaml and install any missing tooling.\n 2. Run \`nerve start\` to launch the daemon.\n`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async function runInitWorkspace(force: boolean): Promise<void> {
|
async function runInitWorkspace(force: boolean): Promise<void> {
|
||||||
const nerveRoot = getNerveRoot();
|
const nerveRoot = getNerveRoot();
|
||||||
|
|
||||||
@@ -294,7 +364,7 @@ export const initCommand = defineCommand({
|
|||||||
meta: {
|
meta: {
|
||||||
name: "init",
|
name: "init",
|
||||||
description:
|
description:
|
||||||
"Initialize workspace (nerve init) or scaffold templates (nerve init workflow <name>)",
|
"Initialize workspace (nerve init), clone from git (nerve init --from <url>), or scaffold templates (nerve init workflow <name>)",
|
||||||
},
|
},
|
||||||
args: {
|
args: {
|
||||||
force: {
|
force: {
|
||||||
@@ -302,12 +372,21 @@ export const initCommand = defineCommand({
|
|||||||
description: "Reinitialize even if workspace already exists (preserves data/)",
|
description: "Reinitialize even if workspace already exists (preserves data/)",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
from: {
|
||||||
|
type: "string",
|
||||||
|
description: "Clone an existing git repo into ~/.uncaged-nerve instead of scaffolding",
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
subCommands: {
|
subCommands: {
|
||||||
workflow: initWorkflowCommand,
|
workflow: initWorkflowCommand,
|
||||||
workspace: initWorkspaceCommand,
|
workspace: initWorkspaceCommand,
|
||||||
},
|
},
|
||||||
async run({ args }) {
|
async run({ args }) {
|
||||||
|
if (args.from !== undefined) {
|
||||||
|
await runInitFromGit(String(args.from));
|
||||||
|
return;
|
||||||
|
}
|
||||||
await runInitWorkspace(args.force);
|
await runInitWorkspace(args.force);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ async function runDaemon(nerveRoot: string): Promise<void> {
|
|||||||
|
|
||||||
const child = spawn(process.execPath, [bootstrapPath], {
|
const child = spawn(process.execPath, [bootstrapPath], {
|
||||||
detached: true,
|
detached: true,
|
||||||
stdio: ["ignore", logStream.fd, logStream.fd],
|
stdio: ["ignore", (logStream as any).fd, (logStream as any).fd],
|
||||||
env: { ...process.env, NERVE_ROOT: nerveRoot },
|
env: { ...process.env, NERVE_ROOT: nerveRoot },
|
||||||
cwd: nerveRoot,
|
cwd: nerveRoot,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
"composite": false,
|
"composite": false,
|
||||||
"types": ["node"]
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src"],
|
||||||
|
"exclude": ["src/__tests__"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
import { defineConfig } from "tsup";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
entry: ["src/index.ts", "src/cli.ts", "src/daemon-bootstrap.ts"],
|
|
||||||
format: ["esm"],
|
|
||||||
dts: true,
|
|
||||||
clean: true,
|
|
||||||
banner: {
|
|
||||||
js: "#!/usr/bin/env node",
|
|
||||||
},
|
|
||||||
/** Daemon is loaded from workspace node_modules at runtime — never bundle it. */
|
|
||||||
external: ["@uncaged/nerve-daemon"],
|
|
||||||
});
|
|
||||||
@@ -3,20 +3,23 @@
|
|||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"files": ["dist"],
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
|
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
|
||||||
"build": "tsup",
|
"build": "rslib build",
|
||||||
"test": "vitest run"
|
"test": "vitest run"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"yaml": "^2.8.3"
|
"yaml": "^2.8.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@rslib/core": "^0.21.3",
|
||||||
"vitest": "^4.1.5"
|
"vitest": "^4.1.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { defineConfig } from "@rslib/core";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
lib: [
|
||||||
|
{
|
||||||
|
format: "esm",
|
||||||
|
dts: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
source: {
|
||||||
|
entry: {
|
||||||
|
index: "src/index.ts",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
target: "node",
|
||||||
|
cleanDistPath: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { defineConfig } from "tsup";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
entry: ["src/index.ts"],
|
|
||||||
format: ["esm"],
|
|
||||||
dts: true,
|
|
||||||
clean: true,
|
|
||||||
});
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
|
"prepublishOnly": "bash ../../scripts/prepublish-check.sh",
|
||||||
"build": "tsup",
|
"build": "rslib build",
|
||||||
"test": "vitest run"
|
"test": "vitest run"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"yaml": "^2.8.3"
|
"yaml": "^2.8.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@rslib/core": "^0.21.3",
|
||||||
"@types/node": "^22.0.0",
|
"@types/node": "^22.0.0",
|
||||||
"vitest": "^4.1.5"
|
"vitest": "^4.1.5"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { defineConfig } from "@rslib/core";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
lib: [
|
||||||
|
{
|
||||||
|
format: "esm",
|
||||||
|
dts: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
source: {
|
||||||
|
entry: {
|
||||||
|
index: "src/index.ts",
|
||||||
|
"sense-worker": "src/sense-worker.ts",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
target: "node",
|
||||||
|
cleanDistPath: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -335,7 +335,7 @@ export function createLogStore(dbPath: string): LogStore {
|
|||||||
|
|
||||||
function query(filter: LogQuery = {}): LogEntry[] {
|
function query(filter: LogQuery = {}): LogEntry[] {
|
||||||
const conditions: string[] = [];
|
const conditions: string[] = [];
|
||||||
const params: Record<string, unknown> = {};
|
const params: Record<string, string | number> = {};
|
||||||
|
|
||||||
if (filter.source !== undefined) {
|
if (filter.source !== undefined) {
|
||||||
conditions.push("source = @source");
|
conditions.push("source = @source");
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { defineConfig } from "tsup";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
entry: ["src/index.ts", "src/sense-worker.ts"],
|
|
||||||
format: ["esm"],
|
|
||||||
dts: true,
|
|
||||||
clean: true,
|
|
||||||
});
|
|
||||||
Generated
+277
-478
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user