orizu 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs'
2
+ import { dirname, isAbsolute, relative, resolve } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ const scriptDir = dirname(fileURLToPath(import.meta.url))
6
+ const cliRoot = resolve(scriptDir, '..')
7
+ const repoRoot = resolve(cliRoot, '..', '..')
8
+ const sourceRoot = resolve(repoRoot, 'skills', 'orizu-cli')
9
+ const vendorRoot = resolve(cliRoot, 'vendor', 'skills', 'orizu-cli')
10
+ const shouldClean = process.argv.includes('--clean')
11
+ const hasSourceSkill = existsSync(resolve(sourceRoot, 'SKILL.md'))
12
+ const hasVendoredSkill = existsSync(resolve(vendorRoot, 'SKILL.md'))
13
+
14
+ function isSafeRelativeSkillPath(rel) {
15
+ return rel !== '..' && !rel.startsWith('../') && !isAbsolute(rel)
16
+ }
17
+
18
+ function shouldCopyPath(sourcePath) {
19
+ const rel = relative(sourceRoot, sourcePath).replace(/\\/g, '/')
20
+ if (!rel) {
21
+ return true
22
+ }
23
+ if (!isSafeRelativeSkillPath(rel)) {
24
+ return false
25
+ }
26
+
27
+ const parts = rel.split('/')
28
+ return !parts.some(part =>
29
+ part === '.DS_Store' ||
30
+ part === '__pycache__' ||
31
+ part === '.pytest_cache'
32
+ ) && !rel.endsWith('.pyc') && !rel.endsWith('.pyo')
33
+ }
34
+
35
+ if (shouldClean) {
36
+ if (hasSourceSkill) {
37
+ rmSync(vendorRoot, { recursive: true, force: true })
38
+ }
39
+ process.exit(0)
40
+ }
41
+
42
+ if (!hasSourceSkill) {
43
+ if (hasVendoredSkill) {
44
+ process.exit(0)
45
+ }
46
+ throw new Error(`Unable to vendor orizu-cli skill: source skill not found at ${sourceRoot}`)
47
+ }
48
+
49
+ rmSync(vendorRoot, { recursive: true, force: true })
50
+ mkdirSync(vendorRoot, { recursive: true })
51
+ cpSync(sourceRoot, vendorRoot, {
52
+ recursive: true,
53
+ filter: shouldCopyPath,
54
+ })