refactor(core): move shared runtime into workspace package
This commit is contained in:
@@ -7,7 +7,7 @@ import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { acquireWriterLease } from '../scripts/writer-lease.ts';
|
||||
import { acquireWriterLease } from '../packages/core/src/writer-lease.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
@@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { buildIndex } from '../app/src/main/indexer.ts';
|
||||
import { acquireWriterLease, writerLockPathFor } from '../scripts/writer-lease.ts';
|
||||
import { acquireWriterLease, writerLockPathFor } from '../packages/core/src/writer-lease.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
@@ -8,7 +8,7 @@ import { mkdtempSync, writeFileSync, statSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { parse } from '../scripts/providers/claude.ts';
|
||||
import { parse } from '../packages/core/src/providers/claude.ts';
|
||||
|
||||
function writeFixture() {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'obelisk-claude-parse-'));
|
||||
|
||||
@@ -17,7 +17,7 @@ const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
function runRuntime(args, home) {
|
||||
return spawnSync(process.execPath, ['scripts/runtime.mjs', ...args], {
|
||||
return spawnSync(process.execPath, ['packages/core/src/runtime.mjs', ...args], {
|
||||
cwd: repoRoot, env: { ...process.env, HOME: home }, encoding: 'utf8',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import { mkdtempSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { parse } from '../scripts/providers/codex.ts';
|
||||
import { parse } from '../packages/core/src/providers/codex.ts';
|
||||
|
||||
function writeFixture(lines) {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'obelisk-codex-parse-'));
|
||||
|
||||
@@ -23,11 +23,11 @@ import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { createQueryApi, createAttuneApi } from '../scripts/query.mjs';
|
||||
import { createQueryApi, createAttuneApi } from '../packages/core/src/query.mjs';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
const SCHEMA = readFileSync(new URL('../scripts/schema.sql', import.meta.url), 'utf8');
|
||||
const SCHEMA = readFileSync(new URL('../packages/core/src/schema.sql', import.meta.url), 'utf8');
|
||||
const API_REFERENCE = readFileSync(new URL('../references/api-reference.md', import.meta.url), 'utf8');
|
||||
|
||||
// Every key asserted below is recorded here so the doc-sync guard can confirm
|
||||
|
||||
@@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
import { acquireWriterLease, writerLockPathFor } from '../scripts/writer-lease.ts';
|
||||
import { acquireWriterLease, writerLockPathFor } from '../packages/core/src/writer-lease.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
@@ -27,7 +27,7 @@ test('a passive query does not mutate the index while a fresh daemon owns writes
|
||||
|
||||
const queryPath = join(home, 'query.mjs');
|
||||
writeFileSync(queryPath, "return 'read-only';");
|
||||
const result = spawnSync(process.execPath, ['scripts/runtime.mjs', '--query', queryPath], {
|
||||
const result = spawnSync(process.execPath, ['packages/core/src/runtime.mjs', '--query', queryPath], {
|
||||
cwd: repoRoot,
|
||||
env: { ...process.env, HOME: home },
|
||||
encoding: 'utf8',
|
||||
@@ -55,7 +55,7 @@ test('attune refuses to mutate the index while a fresh daemon owns writes', () =
|
||||
|
||||
const attunePath = join(home, 'attune.mjs');
|
||||
writeFileSync(attunePath, 'return true;');
|
||||
const result = spawnSync(process.execPath, ['scripts/runtime.mjs', '--attune', attunePath], {
|
||||
const result = spawnSync(process.execPath, ['packages/core/src/runtime.mjs', '--attune', attunePath], {
|
||||
cwd: repoRoot,
|
||||
env: { ...process.env, HOME: home },
|
||||
encoding: 'utf8',
|
||||
@@ -86,7 +86,7 @@ test('a passive query stays read-only when another process holds the writer leas
|
||||
try {
|
||||
const queryPath = join(home, 'query.mjs');
|
||||
writeFileSync(queryPath, "return 'writer-busy';");
|
||||
const result = spawnSync(process.execPath, ['scripts/runtime.mjs', '--query', queryPath], {
|
||||
const result = spawnSync(process.execPath, ['packages/core/src/runtime.mjs', '--query', queryPath], {
|
||||
cwd: repoRoot,
|
||||
env: { ...process.env, HOME: home },
|
||||
encoding: 'utf8',
|
||||
@@ -120,7 +120,7 @@ test('a passive query fails closed when daemon ownership cannot be read', () =>
|
||||
try {
|
||||
const queryPath = join(home, 'query.mjs');
|
||||
writeFileSync(queryPath, "return 'ownership-unknown';");
|
||||
const result = spawnSync(process.execPath, ['scripts/runtime.mjs', '--query', queryPath], {
|
||||
const result = spawnSync(process.execPath, ['packages/core/src/runtime.mjs', '--query', queryPath], {
|
||||
cwd: repoRoot,
|
||||
env: { ...process.env, HOME: home },
|
||||
encoding: 'utf8',
|
||||
|
||||
@@ -2,10 +2,10 @@ import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
import { extractContentType, extractMessageIsMeta } from '../scripts/db.mjs';
|
||||
import { extractContentType, extractMessageIsMeta } from '../packages/core/src/db.mjs';
|
||||
|
||||
async function readExecutableSchema() {
|
||||
return readFile(new URL('../scripts/schema.sql', import.meta.url), 'utf8');
|
||||
return readFile(new URL('../packages/core/src/schema.sql', import.meta.url), 'utf8');
|
||||
}
|
||||
|
||||
async function readSchemaReference() {
|
||||
@@ -21,7 +21,7 @@ async function readSkill() {
|
||||
}
|
||||
|
||||
test('db module loads the executable schema from scripts/schema.sql', async () => {
|
||||
const source = await readFile(new URL('../scripts/db.mjs', import.meta.url), 'utf8');
|
||||
const source = await readFile(new URL('../packages/core/src/db.mjs', import.meta.url), 'utf8');
|
||||
|
||||
assert.match(source, /schema\.sql/);
|
||||
assert.doesNotMatch(source, /CREATE TABLE IF NOT EXISTS sessions/);
|
||||
|
||||
@@ -19,7 +19,7 @@ const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
function runRuntime(args, home) {
|
||||
return spawnSync(process.execPath, ['scripts/runtime.mjs', ...args], {
|
||||
return spawnSync(process.execPath, ['packages/core/src/runtime.mjs', ...args], {
|
||||
cwd: repoRoot, env: { ...process.env, HOME: home }, encoding: 'utf8',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import { mkdtempSync, writeFileSync, readFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { parse } from '../scripts/providers/claude.ts';
|
||||
import { persist } from '../scripts/persist.ts';
|
||||
import { parse } from '../packages/core/src/providers/claude.ts';
|
||||
import { persist } from '../packages/core/src/persist.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
const SCHEMA = readFileSync(new URL('../scripts/schema.sql', import.meta.url), 'utf8');
|
||||
const SCHEMA = readFileSync(new URL('../packages/core/src/schema.sql', import.meta.url), 'utf8');
|
||||
|
||||
function fixtureUnit() {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'obelisk-drift-'));
|
||||
|
||||
@@ -2,7 +2,7 @@ import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
import { inferProjectPath, refreshSessionProjectPaths, shouldSkipBuild } from '../scripts/indexer.mjs';
|
||||
import { inferProjectPath, refreshSessionProjectPaths, shouldSkipBuild } from '../packages/core/src/indexer.mjs';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
@@ -9,12 +9,12 @@ import { mkdtempSync, writeFileSync, readFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { parse } from '../scripts/providers/claude.ts';
|
||||
import { persist } from '../scripts/persist.ts';
|
||||
import { parse } from '../packages/core/src/providers/claude.ts';
|
||||
import { persist } from '../packages/core/src/persist.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
const SCHEMA = readFileSync(new URL('../scripts/schema.sql', import.meta.url), 'utf8');
|
||||
const SCHEMA = readFileSync(new URL('../packages/core/src/schema.sql', import.meta.url), 'utf8');
|
||||
|
||||
function fixtureUnit() {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'obelisk-persist-'));
|
||||
|
||||
@@ -5,11 +5,11 @@ import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { createQueryApi, createAttuneApi } from '../scripts/query.mjs';
|
||||
import { createQueryApi, createAttuneApi } from '../packages/core/src/query.mjs';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
const SCHEMA = readFileSync(new URL('../scripts/schema.sql', import.meta.url), 'utf8');
|
||||
const SCHEMA = readFileSync(new URL('../packages/core/src/schema.sql', import.meta.url), 'utf8');
|
||||
|
||||
function memoryDb({ projectPath = '/tmp/quiet-zero-test' } = {}) {
|
||||
const db = new DatabaseSync(':memory:');
|
||||
|
||||
@@ -23,7 +23,7 @@ import { spawnSync } from 'node:child_process';
|
||||
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
function runRuntime(args, { home }) {
|
||||
return spawnSync(process.execPath, ['scripts/runtime.mjs', ...args], {
|
||||
return spawnSync(process.execPath, ['packages/core/src/runtime.mjs', ...args], {
|
||||
cwd: repoRoot,
|
||||
env: { ...process.env, HOME: home },
|
||||
encoding: 'utf8',
|
||||
|
||||
@@ -12,7 +12,7 @@ const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
function runRuntime(args, { home }) {
|
||||
return spawnSync(process.execPath, ['scripts/runtime.mjs', ...args], {
|
||||
return spawnSync(process.execPath, ['packages/core/src/runtime.mjs', ...args], {
|
||||
cwd: repoRoot,
|
||||
env: { ...process.env, HOME: home },
|
||||
encoding: 'utf8',
|
||||
|
||||
@@ -5,8 +5,8 @@ import { mkdtempSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { nodeSqliteTransactionAdapter, runWriteTransaction } from '../scripts/tx.ts';
|
||||
import { hasUnusableTransaction, isBeginBusyFailure, isRetryableWriteFailure } from '../scripts/write-coordinator.ts';
|
||||
import { nodeSqliteTransactionAdapter, runWriteTransaction } from '../packages/core/src/tx.ts';
|
||||
import { hasUnusableTransaction, isBeginBusyFailure, isRetryableWriteFailure } from '../packages/core/src/write-coordinator.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
@@ -5,7 +5,7 @@ import { mkdtempSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { acquireWriterLease } from '../scripts/writer-lease.ts';
|
||||
import { acquireWriterLease } from '../packages/core/src/writer-lease.ts';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
Reference in New Issue
Block a user