skill-organizer 0.0.4 → 1.0.0

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This package installs the `skill-organizer` CLI by downloading the matching prebuilt binary from GitHub Releases.
4
4
 
5
- Agent-first install and onboarding instructions are documented in [`../../AGENTS_README.md`](../../AGENTS_README.md).
5
+ Agent-first install and onboarding instructions are documented in [`../../../AGENTS_README.md`](../../../AGENTS_README.md).
6
6
 
7
7
  ## Install
8
8
 
@@ -19,6 +19,7 @@ skill-organizer --version
19
19
  ## Notes
20
20
 
21
21
  - The install script downloads a release artifact for your current OS and architecture.
22
+ - The install script only downloads from `sergiocarracedo/skill-organizer` GitHub Releases.
22
23
  - The package version must match an existing GitHub release and its uploaded assets.
23
24
  - Installs with `--ignore-scripts` are not supported.
24
25
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "skill-organizer",
3
- "version": "0.0.4",
3
+ "version": "1.0.0",
4
4
  "description": "Install the skill-organizer CLI from GitHub Releases",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://github.com/sergiocarracedo/skill-organizer",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/sergiocarracedo/skill-organizer.git",
10
- "directory": "cli/packages/npm"
10
+ "directory": "packages/cli/packages/npm"
11
11
  },
12
12
  "bugs": {
13
13
  "url": "https://github.com/sergiocarracedo/skill-organizer/issues"
@@ -10,10 +10,11 @@ const { spawn } = require("node:child_process");
10
10
 
11
11
  const pkg = require("../package.json");
12
12
 
13
- const owner = process.env.SKILL_ORGANIZER_GITHUB_OWNER || "sergiocarracedo";
14
- const repo = process.env.SKILL_ORGANIZER_GITHUB_REPO || "skill-organizer";
13
+ const owner = "sergiocarracedo";
14
+ const repo = "skill-organizer";
15
15
  const version = pkg.version;
16
16
  const tag = `v${version}`;
17
+ const allowedRedirectHosts = new Set(["github.com", "release-assets.githubusercontent.com"]);
17
18
  const osMap = {
18
19
  linux: "Linux",
19
20
  darwin: "Darwin",
@@ -25,6 +26,11 @@ const archMap = {
25
26
  };
26
27
 
27
28
  async function main() {
29
+ if (isSourceCheckoutInstall()) {
30
+ console.log("Skipping binary download for source checkout install.");
31
+ return;
32
+ }
33
+
28
34
  const osName = osMap[process.platform];
29
35
  const archName = archMap[process.arch];
30
36
  if (!osName || !archName) {
@@ -69,12 +75,42 @@ async function main() {
69
75
  await fsp.rm(tmpDir, { recursive: true, force: true });
70
76
  }
71
77
 
78
+ function isSourceCheckoutInstall() {
79
+ let current = path.resolve(__dirname, "..");
80
+
81
+ while (true) {
82
+ const manifestPath = path.join(current, "package.json");
83
+ if (fs.existsSync(manifestPath)) {
84
+ try {
85
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
86
+ if (manifest.name === "skill-organizer-monorepo" && manifest.private === true) {
87
+ return true;
88
+ }
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+
94
+ const parent = path.dirname(current);
95
+ if (parent === current) {
96
+ return false;
97
+ }
98
+ current = parent;
99
+ }
100
+ }
101
+
72
102
  function download(url, destination) {
73
103
  return new Promise((resolve, reject) => {
74
104
  https.get(url, (response) => {
75
105
  if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
106
+ const redirect = new URL(response.headers.location, url);
107
+ if (redirect.protocol !== "https:" || !allowedRedirectHosts.has(redirect.hostname)) {
108
+ reject(new Error(`refusing redirect to unexpected host: ${redirect.origin}`));
109
+ response.resume();
110
+ return;
111
+ }
76
112
  response.resume();
77
- download(response.headers.location, destination).then(resolve, reject);
113
+ download(redirect.toString(), destination).then(resolve, reject);
78
114
  return;
79
115
  }
80
116