opencode-fs-plugin 1.4.3 → 1.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.
- package/INSTALL.md +9 -9
- package/README.md +37 -8
- package/SPEC.md +31 -0
- package/package.json +1 -1
- package/skills/filesystem/SKILL.md +34 -9
- package/src/core/errors.ts +1 -1
- package/src/core/fsutil.ts +44 -17
- package/src/core/magic.ts +51 -0
- package/src/core/procfs.ts +84 -0
- package/src/index.ts +52 -0
- package/src/tools/ar.ts +179 -0
- package/src/tools/base64.ts +63 -0
- package/src/tools/chown.ts +89 -0
- package/src/tools/comm.ts +85 -0
- package/src/tools/cpio.ts +259 -0
- package/src/tools/date.ts +61 -0
- package/src/tools/dd.ts +120 -0
- package/src/tools/file.ts +62 -0
- package/src/tools/findmnt.ts +74 -0
- package/src/tools/fold.ts +64 -0
- package/src/tools/id.ts +70 -0
- package/src/tools/kill.ts +60 -0
- package/src/tools/mountpoint.ts +57 -0
- package/src/tools/nl.ts +51 -0
- package/src/tools/od.ts +58 -0
- package/src/tools/paste.ts +78 -0
- package/src/tools/pgrep.ts +59 -0
- package/src/tools/pipe.ts +13 -1
- package/src/tools/ps.ts +88 -0
- package/src/tools/rev.ts +41 -0
- package/src/tools/shuf.ts +49 -0
- package/src/tools/split.ts +103 -0
- package/src/tools/strings.ts +57 -0
- package/src/tools/sync.ts +51 -0
- package/src/tools/tac.ts +40 -0
- package/src/tools/uname.ts +45 -0
- package/src/tools/uptime.ts +46 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
3
|
+
* license-wizard managed-header v1 EPL-2.0 short 73897e75828f
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as os from "node:os";
|
|
7
|
+
import { Type, type Static } from "@sinclair/typebox";
|
|
8
|
+
import { textResult, type ToolSpec } from "../core/types.js";
|
|
9
|
+
|
|
10
|
+
const Schema = Type.Object(
|
|
11
|
+
{
|
|
12
|
+
pretty: Type.Optional(Type.Boolean({ description: "Human-readable duration instead of seconds (`-p`)." })),
|
|
13
|
+
loadAverage: Type.Optional(Type.Boolean({ description: "Append the 1/5/15-minute load averages." })),
|
|
14
|
+
},
|
|
15
|
+
{ additionalProperties: false },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
type Input = Static<typeof Schema>;
|
|
19
|
+
|
|
20
|
+
export const uptimeTool: ToolSpec<Input> = {
|
|
21
|
+
name: "uptime",
|
|
22
|
+
description: "Print system uptime in seconds or human-readable form, optionally with load averages.",
|
|
23
|
+
schema: Schema,
|
|
24
|
+
pipeable: false,
|
|
25
|
+
mutates: false,
|
|
26
|
+
async run(ctx, input) {
|
|
27
|
+
await ctx.permission.assertTrusted(["*"]);
|
|
28
|
+
const seconds = os.uptime();
|
|
29
|
+
const base = input.pretty === true ? pretty(seconds) : `${seconds.toFixed(2)} seconds`;
|
|
30
|
+
const load = input.loadAverage === true
|
|
31
|
+
? ` load average: ${os.loadavg().map((value) => value.toFixed(2)).join(", ")}`
|
|
32
|
+
: "";
|
|
33
|
+
return textResult(`${base}${load}\n`, { seconds, load: os.loadavg() });
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function pretty(seconds: number): string {
|
|
38
|
+
const days = Math.floor(seconds / 86_400);
|
|
39
|
+
const hours = Math.floor((seconds % 86_400) / 3_600);
|
|
40
|
+
const minutes = Math.floor((seconds % 3_600) / 60);
|
|
41
|
+
const parts: string[] = [];
|
|
42
|
+
if (days > 0) parts.push(`${days} day${days === 1 ? "" : "s"}`);
|
|
43
|
+
if (hours > 0) parts.push(`${hours} hour${hours === 1 ? "" : "s"}`);
|
|
44
|
+
parts.push(`${minutes} minute${minutes === 1 ? "" : "s"}`);
|
|
45
|
+
return `up ${parts.join(", ")}`;
|
|
46
|
+
}
|