fix: advance offline demo from original conversation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { copyReleaseTree } from './release-copy.mjs';
|
||||
|
||||
export const REQUIRED_REPORTS = Object.freeze(['docs/RESEARCH.md', 'docs/research/CURSOR-MECHANISMS.md', 'docs/research/CONTEXT-RECOVERY.md', 'docs/research/TOOL-LOOP.md']);
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
@@ -29,9 +30,9 @@ export function createDocumentationBundle({ root, portableRoot, evidenceRoot, ar
|
||||
const selected = new Set(entries.filter(row => /^docs\/[^/]+\.md$/.test(row.path) || /^docs\/research\/[^/]+\.(?:md|json)$/.test(row.path)).map(row => row.path));
|
||||
const references = [], shipped = [];
|
||||
fs.mkdirSync(evidenceRoot, { recursive: true });
|
||||
copyReleaseTree(path.join(root, 'docs'), path.join(evidenceRoot, 'docs'));
|
||||
for (const row of entries) {
|
||||
const target = path.join(evidenceRoot, row.path); fs.mkdirSync(path.dirname(target), { recursive: true });
|
||||
fs.copyFileSync(path.join(root, row.path), target);
|
||||
const target = path.join(evidenceRoot, row.path);
|
||||
if (hash(fs.readFileSync(target)) !== row.sha256) throw new Error('Original evidence copy differs: ' + row.path);
|
||||
}
|
||||
const evidenceManifest = { schema: 1, app: 'agent-workbench-evidence', sourceCommit, scope: 'Original docs tree, including all successful/failed historical evidence. No runtime execution dependency.', files: entries };
|
||||
|
||||
+2
-4
@@ -8,6 +8,7 @@ import { planDesktopBundle, buildNativeLauncher, copyDesktopBundle } from './bun
|
||||
import { buildWindowsInstaller } from './build-installer.mjs';
|
||||
import { createDocumentationBundle } from './documentation-bundle.mjs';
|
||||
import { archiveWindowsDirectory } from './release-archive.mjs';
|
||||
import { copyReleaseTree } from './release-copy.mjs';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.some(value => !['--help', '--immutable'].includes(value))) throw new Error('Unsupported argument; use --help.');
|
||||
@@ -33,10 +34,7 @@ for (const target of [portableRoot, sourceRoot]) {
|
||||
|
||||
const portableFiles = ['dist-client', 'dist-server', 'dist-desktop', 'public', 'examples', 'benchmarks', 'research', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd', 'Start-Desktop.cmd'];
|
||||
const sourceFiles = ['src', 'public', 'scripts', 'tests', 'docs', 'examples', 'benchmarks', 'research', 'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', 'mobile.html', '.gitignore', '.gitattributes', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'task_plan.md', 'findings.md', 'progress.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd', 'Start-Desktop.cmd'];
|
||||
const copyTree = (source, destination) => fs.cpSync(source, destination, { recursive: true, filter: (from, to) => {
|
||||
if (!fs.statSync(from).isFile() || !fs.existsSync(to)) return true;
|
||||
return !fs.readFileSync(from).equals(fs.readFileSync(to));
|
||||
} });
|
||||
const copyTree = copyReleaseTree;
|
||||
for (const name of portableFiles) copyTree(path.join(root, name), path.join(portableRoot, name));
|
||||
fs.mkdirSync(path.join(portableRoot, 'scripts'), { recursive: true });
|
||||
for (const name of ['Start-Workbench.ps1', 'Stop-Workbench.ps1', 'Start-Desktop.ps1', 'upgrade-running.mjs', 'python-check-runner.py']) fs.copyFileSync(path.join(root, 'scripts', name), path.join(portableRoot, 'scripts', name));
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
// Fresh immutable trees can use Windows' parallel copier. Hash manifests and
|
||||
// archive verification remain authoritative; existing outputs are never reused.
|
||||
export function copyReleaseTree(source, destination) {
|
||||
if (process.platform !== 'win32' || !fs.statSync(source).isDirectory() || fs.existsSync(destination)) {
|
||||
fs.cpSync(source, destination, { recursive: true }); return;
|
||||
}
|
||||
const inspect = directory => {
|
||||
if (fs.lstatSync(directory).isSymbolicLink()) throw new Error('Release source cannot contain links: ' + directory);
|
||||
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
||||
const file = path.join(directory, entry.name);
|
||||
if (entry.isSymbolicLink() || !entry.isDirectory() && !entry.isFile()) throw new Error('Release source must contain regular files: ' + file);
|
||||
if (entry.isDirectory()) inspect(file);
|
||||
}
|
||||
};
|
||||
inspect(source); fs.mkdirSync(path.dirname(destination), { recursive: true });
|
||||
try {
|
||||
execFileSync('robocopy.exe', [path.resolve(source), path.resolve(destination), '/E', '/COPY:DAT', '/DCOPY:DAT', '/R:0', '/W:0', '/MT:16', '/XJ', '/NFL', '/NDL', '/NJH', '/NJS', '/NP'],
|
||||
{ windowsHide: true, stdio: 'pipe', maxBuffer: 8 * 1024 * 1024 });
|
||||
} catch (error) {
|
||||
// Robocopy uses 1..7 for successful copies with differences, 8+ for errors.
|
||||
if (!Number.isInteger(error.status) || error.status < 0 || error.status >= 8) throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user