mirror of
https://github.com/blackboxprogramming/context-bridge.git
synced 2026-03-17 06:57:11 -05:00
Agent Coordination: - Epimetheus (Architect) identity assigned and registered - Connected to PS-SHA-∞ memory system (4,059 entries) - Task claimed from marketplace - Broadcasting to other agents Launch Documentation Created: - PUBLISH_TO_NPM.md - Complete npm publishing guide - STRIPE_LIVE_SETUP.md - Stripe live mode setup guide - AGENT_COORDINATION_REPORT.md - Full status and next steps - EPIMETHEUS_SESSION_COMPLETE.md - Session summary - Added all previous documentation to repo Launch Status: 98% Complete Blocked on: User actions (npm login + Stripe products) Ready: Screenshots, testing, submissions, announcements Next Steps: 1. User: npm login && npm publish (10 min) 2. User: Create Stripe products (5 min) 3. Capture 5 screenshots (15 min) 4. Manual testing on 4 platforms (20 min) 5. Submit to Chrome Web Store (30 min) 6. Launch announcements (10 min) Total time to launch: ~90 minutes Agent Body: qwen2.5-coder:7b (open source) Memory Hash: 4e3d2012 Collaboration: ACTIVE Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
91 lines
2.1 KiB
JavaScript
91 lines
2.1 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const lockfile = require('proper-lockfile');
|
|
|
|
const CONFIG_DIR = path.join(os.homedir(), '.context-bridge');
|
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
const LOCK_OPTIONS = {
|
|
retries: {
|
|
retries: 5,
|
|
minTimeout: 100,
|
|
maxTimeout: 2000
|
|
}
|
|
};
|
|
|
|
// Ensure config directory exists
|
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
}
|
|
|
|
// Ensure config file exists (lockfile requires existing file)
|
|
if (!fs.existsSync(CONFIG_FILE)) {
|
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify({}, null, 2));
|
|
}
|
|
|
|
async function readConfig() {
|
|
let release;
|
|
try {
|
|
// Acquire read lock
|
|
release = await lockfile.lock(CONFIG_FILE, { ...LOCK_OPTIONS, realpath: false });
|
|
|
|
const content = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
return JSON.parse(content || '{}');
|
|
} catch (error) {
|
|
// If lock fails or file doesn't exist, return empty config
|
|
return {};
|
|
} finally {
|
|
if (release) await release();
|
|
}
|
|
}
|
|
|
|
async function writeConfig(data) {
|
|
let release;
|
|
try {
|
|
// Acquire write lock
|
|
release = await lockfile.lock(CONFIG_FILE, { ...LOCK_OPTIONS, realpath: false });
|
|
|
|
// Atomic write: write to temp file, then rename
|
|
const tempFile = CONFIG_FILE + '.tmp';
|
|
fs.writeFileSync(tempFile, JSON.stringify(data, null, 2));
|
|
fs.renameSync(tempFile, CONFIG_FILE);
|
|
} catch (error) {
|
|
throw new Error(`Failed to write config: ${error.message}`);
|
|
} finally {
|
|
if (release) await release();
|
|
}
|
|
}
|
|
|
|
async function getConfig() {
|
|
const data = await readConfig();
|
|
return {
|
|
token: data.github_token,
|
|
gistId: data.gist_id,
|
|
gistUrl: data.gist_url,
|
|
rawUrl: data.raw_url,
|
|
lastUpdated: data.last_updated,
|
|
template: data.template,
|
|
name: data.name
|
|
};
|
|
}
|
|
|
|
async function setConfig(key, value) {
|
|
const data = await readConfig();
|
|
data[key] = value;
|
|
await writeConfig(data);
|
|
}
|
|
|
|
function clearConfig() {
|
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
fs.unlinkSync(CONFIG_FILE);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
getConfig,
|
|
setConfig,
|
|
clearConfig,
|
|
CONFIG_DIR,
|
|
CONFIG_FILE
|
|
};
|