@ifi/oh-pi-skills 0.4.4 → 0.5.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.
@@ -11,10 +11,7 @@ versioned_files = [
11
11
  ]
12
12
  scopes = ["core", "cli"]
13
13
  changelog = "changelog.md"
14
- extra_changelog_sections = [
15
- { name = "Notes", types = ["note"] },
16
- { name = "Documentation", types = ["docs"] },
17
- ]
14
+ extra_changelog_sections = [{ name = "Notes", types = ["note"] }, { name = "Documentation", types = ["docs"] }]
18
15
 
19
16
  [[workflows]]
20
17
  name = "release"
@@ -1,6 +1,6 @@
1
- # __PROJECT_TITLE__
1
+ # **PROJECT_TITLE**
2
2
 
3
- __DESCRIPTION__
3
+ **DESCRIPTION**
4
4
 
5
5
  A Rust workspace starter inspired by the structure used in `mdt` and `pina`, with strong defaults for:
6
6
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: web-fetch
3
- description:
4
- Fetch a web page and extract readable text content. Use when user needs to retrieve or read a web
3
+ description: Fetch a web page and extract readable text content. Use when user needs to retrieve or read a web
5
4
  page.
6
5
  ---
7
6
 
@@ -1,28 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
3
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
4
4
 
5
5
  const args = process.argv.slice(2);
6
- const raw = args.includes('--raw');
7
- const url = args.find(a => !a.startsWith('--'));
6
+ const raw = args.includes("--raw");
7
+ const url = args.find((a) => !a.startsWith("--"));
8
8
 
9
- if (!url) { console.error('Usage: fetch.js <url> [--raw]'); process.exit(1); }
9
+ if (!url) {
10
+ console.error("Usage: fetch.js <url> [--raw]");
11
+ process.exit(1);
12
+ }
10
13
 
11
14
  const res = await fetch(url);
12
15
  const html = await res.text();
13
16
 
14
- if (raw) { console.log(html); } else {
15
- const text = html
16
- .replace(/<script[\s\S]*?<\/script>/gi, '')
17
- .replace(/<style[\s\S]*?<\/style>/gi, '')
18
- .replace(/<[^>]+>/g, ' ')
19
- .replace(/&nbsp;/g, ' ')
20
- .replace(/&amp;/g, '&')
21
- .replace(/&lt;/g, '<')
22
- .replace(/&gt;/g, '>')
23
- .replace(/&#(\d+);/g, (_, n) => String.fromCharCode(n))
24
- .replace(/[ \t]+/g, ' ')
25
- .replace(/\n\s*\n/g, '\n')
26
- .trim();
27
- console.log(text);
17
+ if (raw) {
18
+ console.log(html);
19
+ } else {
20
+ const text = html
21
+ .replaceAll(/<script[\s\S]*?<\/script>/gi, "")
22
+ .replaceAll(/<style[\s\S]*?<\/style>/gi, "")
23
+ .replaceAll(/<[^>]+>/g, " ")
24
+ .replaceAll(/&nbsp;/g, " ")
25
+ .replaceAll(/&amp;/g, "&")
26
+ .replaceAll(/&lt;/g, "<")
27
+ .replaceAll(/&gt;/g, ">")
28
+ .replaceAll(/&#(\d+);/g, (_, n) => String.fromCodePoint(n))
29
+ .replaceAll(/[ \t]+/g, " ")
30
+ .replaceAll(/\n\s*\n/g, "\n")
31
+ .trim();
32
+ console.log(text);
28
33
  }
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: web-search
3
- description:
4
- Web search via DuckDuckGo. Use when the user needs to look up current information online.
3
+ description: Web search via DuckDuckGo. Use when the user needs to look up current information online.
5
4
  ---
6
5
 
7
6
  # web-search
@@ -1,29 +1,45 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const args = process.argv.slice(2);
4
- let n = 5, query;
4
+ let n = 5,
5
+ query;
5
6
 
6
7
  for (let i = 0; i < args.length; i++) {
7
- if (args[i] === '-n' && args[i + 1]) { n = parseInt(args[++i], 10); }
8
- else { query = args[i]; }
8
+ if (args[i] === "-n" && args[i + 1]) {
9
+ n = Number.parseInt(args[++i], 10);
10
+ } else {
11
+ query = args[i];
12
+ }
9
13
  }
10
14
 
11
- if (!query) { console.error('Usage: search.js [-n count] "query"'); process.exit(1); }
15
+ if (!query) {
16
+ console.error('Usage: search.js [-n count] "query"');
17
+ process.exit(1);
18
+ }
12
19
 
13
20
  const res = await fetch(`https://html.duckduckgo.com/html/?q=${encodeURIComponent(query)}`, {
14
- headers: { 'User-Agent': 'Mozilla/5.0' }
21
+ headers: { "User-Agent": "Mozilla/5.0" },
15
22
  });
16
23
  const html = await res.text();
17
24
 
18
25
  const results = [];
19
- const blockRe = /<a rel="nofollow" class="result__a" href="([^"]*)"[^>]*>([\s\S]*?)<\/a>[\s\S]*?<a class="result__snippet"[^>]*>([\s\S]*?)<\/a>/g;
26
+ const blockRe =
27
+ /<a rel="nofollow" class="result__a" href="([^"]*)"[^>]*>([\s\S]*?)<\/a>[\s\S]*?<a class="result__snippet"[^>]*>([\s\S]*?)<\/a>/g;
20
28
  let m;
21
29
  while ((m = blockRe.exec(html)) && results.length < n) {
22
- const url = decodeURIComponent(m[1].replace(/^\/\/duckduckgo\.com\/l\/\?uddg=/, '').replace(/&amp;rut=.*$/, '').replace(/&rut=.*$/, ''));
23
- const title = m[2].replace(/<[^>]*>/g, '').trim();
24
- const snippet = m[3].replace(/<[^>]*>/g, '').trim();
25
- results.push({ title, url, snippet });
30
+ const url = decodeURIComponent(
31
+ m[1]
32
+ .replace(/^\/\/duckduckgo\.com\/l\/\?uddg=/, "")
33
+ .replace(/&amp;rut=.*$/, "")
34
+ .replace(/&rut=.*$/, ""),
35
+ );
36
+ const title = m[2].replaceAll(/<[^>]*>/g, "").trim();
37
+ const snippet = m[3].replaceAll(/<[^>]*>/g, "").trim();
38
+ results.push({ snippet, title, url });
26
39
  }
27
40
 
28
- if (!results.length) { console.log('No results found.'); }
29
- else { results.forEach((r, i) => console.log(`${i + 1}. ${r.title}\n ${r.url}\n ${r.snippet}\n`)); }
41
+ if (results.length === 0) {
42
+ console.log("No results found.");
43
+ } else {
44
+ results.forEach((r, i) => console.log(`${i + 1}. ${r.title}\n ${r.url}\n ${r.snippet}\n`));
45
+ }