Skip to content
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ Test fixture provides:
## Runtime

The CLI entrypoint (`cli/entrypoint.js`) selects between Bun and tsx as the TypeScript runner, preferring Bun when available. This allows hot-reload during development while maintaining Node.js compatibility.
# bump 1777865639
# bump 1777865726
# bump 1777867209
# bump 1777910411
# bump 1777953607
# bump 1777996807
# bump 1778040013
# bump 1778083216
# bump 1778126413
5 changes: 5 additions & 0 deletions lib/shared/export-snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const ALLOWED_EXPORT_FORMATS = [
"srj",
"step",
"assembly-svg",
"pnp-csv",
] as const

export type ExportFormat = (typeof ALLOWED_EXPORT_FORMATS)[number]
Expand All @@ -76,6 +77,7 @@ const OUTPUT_EXTENSIONS: Record<ExportFormat, string> = {
"kicad-library": "",
srj: ".simple-route.json",
step: ".step",
"pnp-csv": "-pnp.csv",
}

const isRecord = (value: unknown): value is Record<string, unknown> =>
Expand Down Expand Up @@ -345,6 +347,9 @@ export const exportSnippet = async ({
case "assembly-svg":
outputContent = convertCircuitJsonToAssemblySvg(circuitJson)
break
case "pnp-csv":
outputContent = await convertCircuitJsonToPickAndPlaceCsv(circuitJson)
break
default:
outputContent = JSON.stringify(circuitJson, null, 2)
}
Expand Down
22 changes: 21 additions & 1 deletion lib/shared/push-snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import semver from "semver"
import Debug from "debug"
import kleur from "kleur"
import { getEntrypoint } from "./get-entrypoint"
import { globbySync } from "globby"
import prompts from "lib/utils/prompts"
import { getUnscopedPackageName } from "lib/utils/get-unscoped-package-name"
import { getPackageAuthor } from "lib/utils/get-package-author"
Expand Down Expand Up @@ -75,12 +76,31 @@ export const pushSnippet = async ({
}

// Detect the entrypoint file
const snippetFilePath = await getEntrypoint({
let snippetFilePath = await getEntrypoint({
filePath,
onSuccess: () => {},
onError,
})

// If no entrypoint found, try to find any valid circuit file (like tsci dev does)
if (!snippetFilePath) {
const projectDir = process.cwd()
const validFiles = globbySync(
["**/*.tsx", "**/*.ts", "**/*.circuit.json"],
{
cwd: projectDir,
ignore: ["node_modules/**", "**/.*"],
},
).filter((relativePath) =>
fs.existsSync(path.join(projectDir, relativePath)),
)

if (validFiles.length > 0) {
snippetFilePath = path.resolve(projectDir, validFiles[0])
onSuccess(`Using fallback file: '${validFiles[0]}'`)
}
}

if (!snippetFilePath) {
return onExit(1)
}
Expand Down