webhand 0.0.0-stage → 0.3.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.
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Where webhand keeps what it learns and does, like Claude Code's ~/.claude and .claude:
3
+ *
4
+ * user $WEBHAND_HOME, or ~/.webhand
5
+ * runbooks/ service information and runbooks for every project
6
+ * runs/ run logs, which hold page text
7
+ * state/ the active session and saved profiles
8
+ * project the nearest .webhand/ from the current directory up
9
+ * runbooks/ service information and runbooks for this project; they win over the user's
10
+ *
11
+ * Sign-ins and logs never go into a project. The Jev key comes only from the environment (TYPESAFE_API_KEY).
12
+ */
13
+ import { execFileSync } from "node:child_process";
14
+ import { statSync } from "node:fs";
15
+ import { homedir } from "node:os";
16
+ import { dirname, join, resolve } from "node:path";
17
+ const FOLDER = ".webhand";
18
+ function expandUser(path) {
19
+ if (path === "~")
20
+ return homedir();
21
+ if (path.startsWith("~/"))
22
+ return join(homedir(), path.slice(2));
23
+ return path;
24
+ }
25
+ /** The user's folder: $WEBHAND_HOME, or ~/.webhand. */
26
+ export function home() {
27
+ return resolve(expandUser(process.env.WEBHAND_HOME || join(homedir(), FOLDER)));
28
+ }
29
+ function isDir(path) {
30
+ try {
31
+ return statSync(path).isDirectory();
32
+ }
33
+ catch {
34
+ return false;
35
+ }
36
+ }
37
+ /** The nearest existing .webhand/ from cwd up, stopping at the home directory. null when there is none. */
38
+ export function projectRoot(cwd = process.cwd()) {
39
+ const stop = homedir();
40
+ const user = home();
41
+ let dir = resolve(cwd);
42
+ while (dir !== stop) {
43
+ const candidate = join(dir, FOLDER);
44
+ if (candidate !== user && isDir(candidate))
45
+ return candidate;
46
+ const parent = dirname(dir);
47
+ if (parent === dir)
48
+ break;
49
+ dir = parent;
50
+ }
51
+ return null;
52
+ }
53
+ function gitRoot(cwd) {
54
+ try {
55
+ const out = execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, stdio: ["ignore", "pipe", "ignore"] });
56
+ return out.toString().trim() || null;
57
+ }
58
+ catch {
59
+ return null;
60
+ }
61
+ }
62
+ /** Where a project's .webhand/ is or will be: the nearest one, else the git root's, else the cwd's. */
63
+ export function projectWriteRoot(cwd = process.cwd()) {
64
+ return projectRoot(cwd) ?? join(gitRoot(cwd) ?? resolve(cwd), FOLDER);
65
+ }
66
+ /** The folder for a scope, whether or not it exists yet. */
67
+ export function scopeRoot(scope) {
68
+ return scope === "user" ? home() : projectWriteRoot();
69
+ }
70
+ /** Existing scopes to read, project first. */
71
+ export function roots() {
72
+ const found = [];
73
+ const project = projectRoot();
74
+ if (project)
75
+ found.push({ scope: "project", dir: project });
76
+ found.push({ scope: "user", dir: home() });
77
+ return found;
78
+ }
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "webhand",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Claude plans, asks, checks, and replans; Jev operates the browser toward the goal.",
5
+ "license": "MIT",
6
+ "author": "sakamoto66",
7
+ "homepage": "https://github.com/sakamoto66/webhand",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sakamoto66/webhand.git"
11
+ },
12
+ "keywords": [
13
+ "browser",
14
+ "agent",
15
+ "automation",
16
+ "runbook",
17
+ "claude-code"
18
+ ],
19
+ "type": "module",
20
+ "bin": {
21
+ "webhand": "dist/bin.js"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "assets",
26
+ "LICENSE",
27
+ "THIRD_PARTY_LICENSE_jev-ultrafast.txt",
28
+ "README.md",
29
+ "README.ja.md"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22"
33
+ },
34
+ "scripts": {
35
+ "build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
36
+ "lint": "biome check .",
37
+ "typecheck": "tsc --noEmit",
38
+ "knip": "knip",
39
+ "check": "npm run lint && npm run typecheck && npm run knip",
40
+ "check:package": "node scripts/check-package.ts",
41
+ "test": "vitest run",
42
+ "test:coverage": "vitest run --coverage",
43
+ "test:golden:update": "UPDATE_GOLDEN=1 vitest run tests/golden.test.ts",
44
+ "smoke": "node research/smoke.ts",
45
+ "prepare": "husky",
46
+ "prepublishOnly": "npm run check && npm run build && npm run check:package"
47
+ },
48
+ "dependencies": {
49
+ "playwright-core": "~1.64.1",
50
+ "smol-toml": "^1.9.1",
51
+ "undici": "^8.12.3"
52
+ },
53
+ "devDependencies": {
54
+ "@biomejs/biome": "^2.6.4",
55
+ "@types/node": "^26.6.6",
56
+ "@vitest/coverage-v8": "^5.1.0",
57
+ "husky": "^9.1.7",
58
+ "knip": "^6.44.1",
59
+ "typescript": "^7.0.2",
60
+ "vitest": "^5.1.0"
61
+ }
62
+ }