checkpoint: pre-split branch cleanup

This commit is contained in:
ZenchantLive 2026-03-03 16:43:42 -08:00
parent 4c2ae2e5b7
commit b5db7a7753
276 changed files with 35912 additions and 60119 deletions

View file

@ -0,0 +1,79 @@
#!/usr/bin/env node
import fs from 'node:fs/promises';
import path from 'node:path';
import { findCommandInPath, resolveBbPath } from './lib/driver-lib.mjs';
async function pathExists(filePath) {
try {
await fs.access(filePath);
return true;
} catch {
return false;
}
}
async function main() {
const timestamp = new Date().toISOString();
const cwd = process.cwd();
const gitIndexLock = path.join(cwd, '.git', 'index.lock');
const findings = [];
const recommendations = [];
const bdPath = await findCommandInPath('bd');
const bb = await resolveBbPath();
const hasGitIndexLock = await pathExists(gitIndexLock);
if (!bdPath) {
findings.push({
code: 'BD_NOT_FOUND',
severity: 'high',
message: 'bd command not found in PATH.',
});
recommendations.push(
'Install BeadBoard tooling from https://github.com/zenchantlive/beadboard or add bd executable directory to PATH.',
);
}
if (!bb.ok) {
findings.push({
code: 'BB_NOT_FOUND',
severity: 'high',
message: bb.reason,
});
if (bb.remediation) {
recommendations.push(bb.remediation);
}
}
if (hasGitIndexLock) {
findings.push({
code: 'GIT_INDEX_LOCK_PRESENT',
severity: 'medium',
message: `Potential stale git lock detected at ${gitIndexLock}`,
});
recommendations.push('Run heal-common-issues.mjs with --apply --fix-git-index-lock if no git process is active.');
}
const payload = {
ok: findings.filter((item) => item.severity === 'high').length === 0,
timestamp,
environment: {
cwd,
project_root: cwd,
platform: process.platform,
node_version: process.version,
},
tools: {
bd: { available: Boolean(bdPath), path: bdPath || null },
bb,
},
findings,
recommendations,
};
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
}
void main();

View file

@ -0,0 +1,85 @@
#!/usr/bin/env node
import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
function parseArgs(argv) {
const args = new Set();
const values = {};
for (let i = 0; i < argv.length; i += 1) {
const token = argv[i];
if (!token.startsWith('--')) {
continue;
}
const key = token.slice(2);
const next = argv[i + 1];
if (!next || next.startsWith('--')) {
args.add(key);
continue;
}
values[key] = next;
i += 1;
}
return { args, values };
}
async function exists(filePath) {
try {
await fs.access(filePath);
return true;
} catch {
return false;
}
}
async function main() {
const { values } = parseArgs(process.argv.slice(2));
const projectRoot = values['project-root'] ? path.resolve(values['project-root']) : process.cwd();
const thisFile = fileURLToPath(import.meta.url);
const skillRoot = path.resolve(path.dirname(thisFile), '..');
const templatePath = path.join(skillRoot, 'project.template.md');
const targetPath = path.join(projectRoot, 'project.md');
const targetExists = await exists(targetPath);
if (targetExists) {
process.stdout.write(
`${JSON.stringify(
{
ok: true,
created: false,
used_existing: true,
project_root: projectRoot,
target_path: targetPath,
template_path: templatePath,
},
null,
2,
)}\n`,
);
return;
}
const template = await fs.readFile(templatePath, 'utf8');
await fs.writeFile(targetPath, template, 'utf8');
process.stdout.write(
`${JSON.stringify(
{
ok: true,
created: true,
used_existing: false,
project_root: projectRoot,
target_path: targetPath,
template_path: templatePath,
},
null,
2,
)}\n`,
);
}
void main();

View file

@ -0,0 +1,104 @@
#!/usr/bin/env node
import fs from 'node:fs/promises';
import path from 'node:path';
function parseArgs(argv) {
const args = new Set();
const values = {};
for (let i = 0; i < argv.length; i += 1) {
const token = argv[i];
if (!token.startsWith('--')) {
continue;
}
const key = token.slice(2);
const next = argv[i + 1];
if (!next || next.startsWith('--')) {
args.add(key);
continue;
}
values[key] = next;
i += 1;
}
return { args, values };
}
async function pathExists(filePath) {
try {
await fs.access(filePath);
return true;
} catch {
return false;
}
}
async function removeIfExists(filePath) {
if (!(await pathExists(filePath))) {
return false;
}
await fs.rm(filePath, { force: true });
return true;
}
async function main() {
const { args, values } = parseArgs(process.argv.slice(2));
const apply = args.has('apply');
const fixGitIndexLock = args.has('fix-git-index-lock');
const projectRoot = values['project-root'] ? path.resolve(values['project-root']) : process.cwd();
const actions = [];
const warnings = [];
const lockPath = path.join(projectRoot, '.git', 'index.lock');
const lockExists = await pathExists(lockPath);
if (fixGitIndexLock && lockExists) {
if (apply) {
const removed = await removeIfExists(lockPath);
actions.push({
id: 'fix-git-index-lock',
attempted: true,
applied: removed,
target: lockPath,
});
} else {
actions.push({
id: 'fix-git-index-lock',
attempted: true,
applied: false,
target: lockPath,
});
warnings.push('Dry-run mode enabled. Re-run with --apply to perform fixes.');
}
} else if (fixGitIndexLock && !lockExists) {
actions.push({
id: 'fix-git-index-lock',
attempted: true,
applied: false,
target: lockPath,
note: 'No index.lock found.',
});
}
if (!fixGitIndexLock && lockExists) {
warnings.push('Stale git index.lock detected. Use --fix-git-index-lock to target it.');
}
process.stdout.write(
`${JSON.stringify(
{
ok: true,
mode: apply ? 'apply' : 'dry-run',
project_root: projectRoot,
actions,
warnings,
},
null,
2,
)}\n`,
);
}
void main();

View file

@ -1,114 +1,114 @@
#!/usr/bin/env node
import fs from 'node:fs/promises';
import path from 'node:path';
function parseArgs(argv) {
const output = {};
for (let index = 0; index < argv.length; index += 1) {
const token = argv[index];
if (!token.startsWith('--')) {
continue;
}
const key = token.slice(2);
const value = argv[index + 1];
if (!value || value.startsWith('--')) {
output[key] = 'true';
continue;
}
output[key] = value;
index += 1;
}
return output;
}
function parseJsonArray(raw, fallback) {
if (!raw) {
return fallback;
}
try {
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed : fallback;
} catch {
return fallback;
}
}
async function withArtifactExistence(artifacts) {
const output = [];
for (const artifact of artifacts) {
const item = {
path: artifact.path,
required: Boolean(artifact.required),
exists: false,
};
if (typeof artifact.path === 'string' && artifact.path.trim()) {
try {
const resolved = path.resolve(artifact.path);
await fs.access(resolved);
item.exists = true;
} catch {
item.exists = false;
}
}
output.push(item);
}
return output;
}
async function main() {
try {
const args = parseArgs(process.argv.slice(2));
const checks = parseJsonArray(args.checks, []);
const artifacts = parseJsonArray(args.artifacts, []);
const dependencySanity = args['dependency-note'] || '';
const normalizedChecks = checks.map((check) => ({
name: check.name || 'unnamed-check',
ok: Boolean(check.ok),
details: check.details || '',
}));
const normalizedArtifacts = await withArtifactExistence(artifacts);
const allChecksPass = normalizedChecks.every((check) => check.ok);
const requiredArtifactsPresent = normalizedArtifacts.every((artifact) => !artifact.required || artifact.exists);
const ready = allChecksPass && requiredArtifactsPresent;
process.stdout.write(
`${JSON.stringify(
{
ok: true,
generated_at: new Date().toISOString(),
checks: normalizedChecks,
artifacts: normalizedArtifacts,
dependency_sanity: dependencySanity,
summary: {
checks_passed: allChecksPass,
required_artifacts_present: requiredArtifactsPresent,
ready,
},
},
null,
2,
)}\n`,
);
} catch (error) {
process.stdout.write(
`${JSON.stringify(
{
ok: false,
reason: error instanceof Error ? error.message : String(error),
summary: {
checks_passed: false,
required_artifacts_present: false,
ready: false,
},
},
null,
2,
)}\n`,
);
}
}
void main();
#!/usr/bin/env node
import fs from 'node:fs/promises';
import path from 'node:path';
function parseArgs(argv) {
const output = {};
for (let index = 0; index < argv.length; index += 1) {
const token = argv[index];
if (!token.startsWith('--')) {
continue;
}
const key = token.slice(2);
const value = argv[index + 1];
if (!value || value.startsWith('--')) {
output[key] = 'true';
continue;
}
output[key] = value;
index += 1;
}
return output;
}
function parseJsonArray(raw, fallback) {
if (!raw) {
return fallback;
}
try {
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed : fallback;
} catch {
return fallback;
}
}
async function withArtifactExistence(artifacts) {
const output = [];
for (const artifact of artifacts) {
const item = {
path: artifact.path,
required: Boolean(artifact.required),
exists: false,
};
if (typeof artifact.path === 'string' && artifact.path.trim()) {
try {
const resolved = path.resolve(artifact.path);
await fs.access(resolved);
item.exists = true;
} catch {
item.exists = false;
}
}
output.push(item);
}
return output;
}
async function main() {
try {
const args = parseArgs(process.argv.slice(2));
const checks = parseJsonArray(args.checks, []);
const artifacts = parseJsonArray(args.artifacts, []);
const dependencySanity = args['dependency-note'] || '';
const normalizedChecks = checks.map((check) => ({
name: check.name || 'unnamed-check',
ok: Boolean(check.ok),
details: check.details || '',
}));
const normalizedArtifacts = await withArtifactExistence(artifacts);
const allChecksPass = normalizedChecks.every((check) => check.ok);
const requiredArtifactsPresent = normalizedArtifacts.every((artifact) => !artifact.required || artifact.exists);
const ready = allChecksPass && requiredArtifactsPresent;
process.stdout.write(
`${JSON.stringify(
{
ok: true,
generated_at: new Date().toISOString(),
checks: normalizedChecks,
artifacts: normalizedArtifacts,
dependency_sanity: dependencySanity,
summary: {
checks_passed: allChecksPass,
required_artifacts_present: requiredArtifactsPresent,
ready,
},
},
null,
2,
)}\n`,
);
} catch (error) {
process.stdout.write(
`${JSON.stringify(
{
ok: false,
reason: error instanceof Error ? error.message : String(error),
summary: {
checks_passed: false,
required_artifacts_present: false,
ready: false,
},
},
null,
2,
)}\n`,
);
}
}
void main();