Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix: make DSH packaging portable on Windows (#70)
tt-a1ifc6e8aca1829
diff --git a/integrations/deepseek-harness/scripts/distribution-acceptance.mjs b/integrations/deepseek-harness/scripts/distribution-acceptance.mjsindex 1cff7ee5..c084ab74 100644--- a/integrations/deepseek-harness/scripts/distribution-acceptance.mjs+++ b/integrations/deepseek-harness/scripts/distribution-acceptance.mjs@@ -16,6 +16,8 @@ const PROFILE = 'archify-dsh-acceptance';const FIXED_POINT = '45f0611dfc0dc824e9a13a12efcac207a8a2bdce';const ARCHIFY_ZIP_BLOB = '4249d32a5a07deb63152a06ac8c2cf4784d25136';const ARCHIFY_PACKAGE_BLOB = '238d6237ff0c942d459e7ec257f19386522306a0';+const DSH_RUNTIME_INSTALL_TIMEOUT = process.platform === 'win32' ? 600_000 : 300_000;+const PLUGIN_MUTATION_TIMEOUT = 180_000;const receipt = {ok: false,@@ -70,7 +72,19 @@ function listRelativeFiles(root) {return files.sort();}-function treesMatch(left, right) {+const CHECKOUT_TEXT_EXTENSIONS = new Set(['.html', '.json', '.md', '.mjs']);++function checkoutContentsEqual(file, left, right, normalizeTextEol) {+ if (left.equals(right)) return true;+ if (!normalizeTextEol) return false;+ const isCheckoutText = path.basename(file) === 'LICENSE'+ || CHECKOUT_TEXT_EXTENSIONS.has(path.extname(file).toLowerCase());+ if (!isCheckoutText) return false;+ return left.toString('utf8').replaceAll('\r\n', '\n')+ === right.toString('utf8').replaceAll('\r\n', '\n');+}++function treesMatch(left, right, { normalizeTextEol = false } = {}) {const leftFiles = listRelativeFiles(left);const rightFiles = listRelativeFiles(right);if (leftFiles.join('\n') !== rightFiles.join('\n')) {@@ -79,7 +93,12 @@ function treesMatch(left, right) {for (const file of leftFiles) {const leftPath = path.join(left, ...file.split('/'));const rightPath = path.join(right, ...file.split('/'));- if (!fs.readFileSync(leftPath).equals(fs.readFileSync(rightPath))) {+ if (!checkoutContentsEqual(+ file,+ fs.readFileSync(leftPath),+ fs.readFileSync(rightPath),+ normalizeTextEol,+ )) {return { ok: false, file };}}@@ -150,10 +169,12 @@ const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-dsh-acceptance-')const tarball = path.join(scratch, 'tt-a1i-archify-dsh-0.1.0.tgz');const dshHome = path.join(scratch, 'dsh-home');const agentsHome = path.join(scratch, 'agents-home');+const dshRuntime = path.join(scratch, 'dsh-runtime');const workspace = path.join(scratch, 'workspace');const probeOut = path.join(scratch, 'skill-probe.json');fs.mkdirSync(dshHome);fs.mkdirSync(agentsHome);+fs.mkdirSync(dshRuntime);fs.mkdirSync(workspace);function cleanup() {@@ -182,7 +203,9 @@ pass('pack', { filename: packReceipt.filename, fileCount: packReceipt.files?.lenconst inspectRoot = path.join(scratch, 'tarball');fs.mkdirSync(inspectRoot);-requireStatus('tarball-inspect', run('tar', ['-xzf', tarball, '-C', inspectRoot]));+requireStatus('tarball-inspect', run('tar', ['-xzf', path.basename(tarball), '-C', inspectRoot], {+ cwd: path.dirname(tarball),+}));const packedPkg = JSON.parse(fs.readFileSync(path.join(inspectRoot, 'package', 'package.json'), 'utf8'));const packedFiles = listRelativeFiles(path.join(inspectRoot, 'package'));const forbidden = packedFiles.filter((file) => (@@ -210,17 +233,49 @@ const dshEnv = {ARCHIFY_DSH_PROBE_OUT: probeOut,npm_config_update_notifier: 'false',};-const npx = ['-y', '--package', DSH_SPEC, 'dsh'];++// Install the pinned host once, as a user-level global install would. Keeping+// this separate from plugin mutation makes a slow first-time npm download+// distinguishable from `dsh plugin add`, especially on Windows runners.+const runtimeInstall = run('npm', [+ 'install',+ '--prefix', dshRuntime,+ '--no-save',+ '--package-lock=false',+ '--no-audit',+ '--no-fund',+ '--foreground-scripts',+ '--loglevel=warn',+ DSH_SPEC,+], {+ cwd: scratch,+ env: dshEnv,+ // Stream npm lifecycle diagnostics without polluting the JSON-only receipt+ // written to this process's stdout.+ stdio: ['ignore', 2, 2],+ timeout: DSH_RUNTIME_INSTALL_TIMEOUT,+});+requireStatus('dsh-runtime-install', runtimeInstall, { command: `npm install ${DSH_SPEC}` });+const dshPackageRoot = path.join(dshRuntime, 'node_modules', '@deepseek-ai', 'dsh');+const dshManifest = JSON.parse(fs.readFileSync(path.join(dshPackageRoot, 'package.json'), 'utf8'));+const dshBin = path.join(dshPackageRoot, 'lib', 'bin.js');+if (dshManifest.version !== DSH_SPEC.slice(DSH_SPEC.lastIndexOf('@') + 1) || !fs.existsSync(dshBin)) {+ fail('dsh-runtime-install', 'installed DSH runtime identity mismatch', {+ version: dshManifest.version,+ binExists: fs.existsSync(dshBin),+ });+}+pass('dsh-runtime-install', { version: dshManifest.version });function dsh(args, options = {}) {- return run('npx', [...npx, ...args], {+ return run(process.execPath, [dshBin, ...args], {cwd: options.cwd || workspace,env: dshEnv,timeout: options.timeout ?? 120_000,});}-const install = dsh(['plugin', '--profile', PROFILE, 'add', tarball], { timeout: 180_000 });+const install = dsh(['plugin', '--profile', PROFILE, 'add', tarball], { timeout: PLUGIN_MUTATION_TIMEOUT });requireStatus('plugin-install', install, { command: `dsh plugin --profile ${PROFILE} add <tarball>` });pass('plugin-install', { profile: PROFILE });@@ -270,7 +325,7 @@ fs.writeFileSync(probePatch, `- insert:name: ${JSON.stringify(pathToFileURL(probeModule).href)}inject: [skills]`);-const probeChild = spawnCli('npx', [...npx, '--profile', PROFILE, '--patch', probePatch], {+const probeChild = spawnCli(process.execPath, [dshBin, '--profile', PROFILE, '--patch', probePatch], {cwd: workspace,env: dshEnv,stdio: ['ignore', 'pipe', 'pipe'],@@ -335,7 +390,7 @@ const smoke = run(process.execPath, [path.join(repoRoot, 'scripts', 'package-smorequireStatus('package-smoke', smoke, { command: 'package-smoke.mjs <installed-skill-root>' });pass('package-smoke', { skillRoot, output: smoke.stdout.trim() });-const remove = dsh(['plugin', '--profile', PROFILE, 'remove', PACKAGE_NAME], { timeout: 180_000 });+const remove = dsh(['plugin', '--profile', PROFILE, 'remove', PACKAGE_NAME], { timeout: PLUGIN_MUTATION_TIMEOUT });requireStatus('uninstall', remove, { command: `dsh plugin --profile ${PROFILE} remove ${PACKAGE_NAME}` });const removedManifest = JSON.parse(fs.readFileSync(path.join(profileDir, 'package.json'), 'utf8'));if ((removedManifest.dsh?.profile?.bundles || []).includes(PACKAGE_NAME)@@ -369,12 +424,12 @@ const committedZip = path.join(repoRoot, 'archify.zip');const packedSkill = path.join(inspectRoot, 'package', 'skills', 'archify');let unzipContentsIdentical = false;if (skipFreshZipRebuild) {- receipt.zipContainerNote = 'Fresh ZIP rebuild skipped on Windows (rsync/zip are not on GitHub Windows runners). Used committed archify.zip for content comparison. ZIP container bytes are already known non-reproducible.';+ receipt.zipContainerNote = 'Fresh ZIP rebuild skipped on Windows (rsync/zip are not on GitHub Windows runners). Used committed archify.zip for content comparison; known text files normalize checkout CRLF while all other files remain byte-exact. ZIP container bytes are already known non-reproducible.';const checkedDir = path.join(scratch, 'checked');fs.mkdirSync(checkedDir);fs.copyFileSync(committedZip, path.join(checkedDir, 'committed.zip'));requireStatus('zero-regression', run('tar', ['-xf', 'committed.zip'], { cwd: checkedDir }));- const compared = treesMatch(packedSkill, path.join(checkedDir, 'archify'));+ const compared = treesMatch(packedSkill, path.join(checkedDir, 'archify'), { normalizeTextEol: true });if (!compared.ok) {fail('zero-regression', 'packed skill drifted from the committed ZIP', compared);}@@ -401,7 +456,7 @@ pass('zero-regression', {archifyPackageBlob: pkgBlob.stdout.trim(),unzipContentsIdentical,zipContainerBytesReproducible: false,- ...(skipFreshZipRebuild ? { freshZipRebuildSkipped: true } : {}),+ ...(skipFreshZipRebuild ? { freshZipRebuildSkipped: true, checkoutTextEolNormalized: true } : {}),skillsCli: skillsList.stdout.trim().slice(0, 500),});diff --git a/integrations/deepseek-harness/scripts/pack.mjs b/integrations/deepseek-harness/scripts/pack.mjsindex 61fa3194..84cc332f 100644--- a/integrations/deepseek-harness/scripts/pack.mjs+++ b/integrations/deepseek-harness/scripts/pack.mjs@@ -93,17 +93,20 @@ try {}),);const parsed = JSON.parse(packed.stdout.slice(jsonStart));- packMeta = Array.isArray(parsed) ? parsed[0] : parsed;+ if (Array.isArray(parsed)) {+ packMeta = parsed[0] || {};+ } else if (parsed?.name) {+ packMeta = parsed;+ } else {+ packMeta = Object.values(parsed || {}).find((entry) => entry?.name === '@tt-a1i/archify-dsh') || {};+ }} catch {packMeta = {};}- const listing = spawnCliSync('tar', ['-tzf', path.join(stage, produced)], { encoding: 'utf8' });- if (listing.status !== 0) {- throw new Error(`unable to list packed tarball: ${listing.stderr || listing.error?.message}`);+ if (!Array.isArray(packMeta.files)) {+ throw new Error(`npm pack metadata did not include a file list\n${packed.stdout}`);}- const files = listing.stdout.trim().split('\n').filter(Boolean).map((entry) => ({- path: entry.replace(/^package\//, ''),- }));+ const files = packMeta.files.map((file) => ({ path: file.path }));const destination = path.resolve(out || path.join(process.cwd(), produced));fs.mkdirSync(path.dirname(destination), { recursive: true });fs.copyFileSync(path.join(stage, produced), destination);diff --git a/integrations/deepseek-harness/scripts/resolve-cli.mjs b/integrations/deepseek-harness/scripts/resolve-cli.mjsindex 1a300229..0dce377e 100644--- a/integrations/deepseek-harness/scripts/resolve-cli.mjs+++ b/integrations/deepseek-harness/scripts/resolve-cli.mjs@@ -36,6 +36,13 @@ function nodeCliPath(command, {export function resolveCliInvocation(command, args = [], options = {}) {const platform = options.platform || process.platform;+ if (platform === 'win32' && command === 'tar') {+ const env = options.env || process.env;+ const existsSync = options.existsSync || fs.existsSync;+ const systemRoot = env.SystemRoot || env.SYSTEMROOT || env.windir || env.WINDIR;+ const systemTar = systemRoot && path.win32.join(systemRoot, 'System32', 'tar.exe');+ if (systemTar && existsSync(systemTar)) return { command: systemTar, args };+ }if (platform === 'win32' && CMD_SHIMS.has(command)) {const cliPath = nodeCliPath(command, options);if (!cliPath) {diff --git a/integrations/deepseek-harness/test/package-contract.test.mjs b/integrations/deepseek-harness/test/package-contract.test.mjsindex f80e04c5..f9a08e15 100644--- a/integrations/deepseek-harness/test/package-contract.test.mjs+++ b/integrations/deepseek-harness/test/package-contract.test.mjs@@ -69,3 +69,14 @@ test('bundle patch inserts one uniquely named filesystem Skill provider resolvedconst insertedIds = [...insertBlocks[0].matchAll(/^\s+- id:\s*(\S+)/gm)].map((match) => match[1]);assert.deepEqual(insertedIds, ['archify-skill-filesystem']);});++test('distribution acceptance reserves stdout for its machine-readable JSON receipt', () => {+ const source = fs.readFileSync(+ path.join(integrationRoot, 'scripts', 'distribution-acceptance.mjs'),+ 'utf8',+ );+ const runtimeInstall = source.match(/const runtimeInstall = run\([\s\S]*?\n\}\);/)?.[0] || '';+ assert.match(runtimeInstall, /stdio:\s*\['ignore',\s*2,\s*2\]/);+ assert.doesNotMatch(source, /stdio:\s*['"]inherit['"]/);+ assert.equal([...source.matchAll(/process\.stdout\.write/g)].length, 2);+});diff --git a/integrations/deepseek-harness/test/resolve-cli.test.mjs b/integrations/deepseek-harness/test/resolve-cli.test.mjsindex e59fb32d..605ce550 100644--- a/integrations/deepseek-harness/test/resolve-cli.test.mjs+++ b/integrations/deepseek-harness/test/resolve-cli.test.mjs@@ -29,6 +29,18 @@ test('Windows npm shims launch their JavaScript CLI through Node', () => {assert.deepEqual(invocation, { command: execPath, args: [npmCli, '--version'] });});+test('Windows tar uses the system bsdtar instead of a Git for Windows PATH shadow', () => {+ const systemTar = 'C:\\Windows\\System32\\tar.exe';+ const invocation = resolveCliInvocation('tar', ['-tf', 'archive.tgz'], {+ platform: 'win32',+ env: { SystemRoot: 'C:\\Windows' },+ existsSync(candidate) {+ return candidate === systemTar;+ },+ });+ assert.deepEqual(invocation, { command: systemTar, args: ['-tf', 'archive.tgz'] });+});+test('resolved npm invocation can actually be spawned', () => {const invocation = resolveCliInvocation('npm', ['--version']);const result = spawnSync(invocation.command, invocation.args, { encoding: 'utf8' });diff --git a/integrations/deepseek-harness/test/tarball-contract.test.mjs b/integrations/deepseek-harness/test/tarball-contract.test.mjsindex ffcc0683..f3e0a2c8 100644--- a/integrations/deepseek-harness/test/tarball-contract.test.mjs+++ b/integrations/deepseek-harness/test/tarball-contract.test.mjs@@ -72,7 +72,10 @@ test('packed Skill payload matches the existing ZIP clean-staging contract', ()assert.equal(result.status, 0, result.stderr || result.stdout);const packedRoot = path.join(scratch, 'packed');fs.mkdirSync(packedRoot);- const tar = spawnSync('tar', ['-xzf', out, '-C', packedRoot], { encoding: 'utf8' });+ const tar = spawnSync('tar', ['-xzf', path.basename(out), '-C', packedRoot], {+ cwd: path.dirname(out),+ encoding: 'utf8',+ });assert.equal(tar.status, 0, tar.stderr);const zipPath = path.join(zipScratch, 'archify.zip');const zip = spawnSync('bash', [path.join(repoRoot, 'scripts', 'build-zip.sh'), zipPath], {