@chrysb/alphaclaw 0.3.2 → 0.3.3

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.
Files changed (36) hide show
  1. package/bin/alphaclaw.js +29 -2
  2. package/lib/cli/git-sync.js +25 -0
  3. package/lib/public/css/explorer.css +983 -0
  4. package/lib/public/css/shell.css +48 -4
  5. package/lib/public/css/theme.css +6 -1
  6. package/lib/public/icons/folder-line.svg +1 -0
  7. package/lib/public/icons/hashtag.svg +3 -0
  8. package/lib/public/icons/home-5-line.svg +1 -0
  9. package/lib/public/icons/save-fill.svg +3 -0
  10. package/lib/public/js/app.js +259 -158
  11. package/lib/public/js/components/action-button.js +12 -1
  12. package/lib/public/js/components/file-tree.js +322 -0
  13. package/lib/public/js/components/file-viewer.js +691 -0
  14. package/lib/public/js/components/icons.js +182 -0
  15. package/lib/public/js/components/sidebar-git-panel.js +149 -0
  16. package/lib/public/js/components/sidebar.js +272 -0
  17. package/lib/public/js/lib/api.js +26 -0
  18. package/lib/public/js/lib/browse-draft-state.js +109 -0
  19. package/lib/public/js/lib/file-highlighting.js +6 -0
  20. package/lib/public/js/lib/file-tree-utils.js +12 -0
  21. package/lib/public/js/lib/syntax-highlighters/css.js +124 -0
  22. package/lib/public/js/lib/syntax-highlighters/frontmatter.js +49 -0
  23. package/lib/public/js/lib/syntax-highlighters/html.js +209 -0
  24. package/lib/public/js/lib/syntax-highlighters/index.js +28 -0
  25. package/lib/public/js/lib/syntax-highlighters/javascript.js +134 -0
  26. package/lib/public/js/lib/syntax-highlighters/json.js +61 -0
  27. package/lib/public/js/lib/syntax-highlighters/markdown.js +37 -0
  28. package/lib/public/js/lib/syntax-highlighters/utils.js +13 -0
  29. package/lib/public/setup.html +1 -0
  30. package/lib/server/constants.js +1 -0
  31. package/lib/server/onboarding/workspace.js +3 -2
  32. package/lib/server/routes/browse.js +295 -0
  33. package/lib/server.js +24 -3
  34. package/lib/setup/core-prompts/TOOLS.md +3 -1
  35. package/lib/setup/skills/control-ui/SKILL.md +12 -20
  36. package/package.json +1 -1
package/bin/alphaclaw.js CHANGED
@@ -5,6 +5,10 @@ const fs = require("fs");
5
5
  const os = require("os");
6
6
  const path = require("path");
7
7
  const { execSync } = require("child_process");
8
+ const {
9
+ normalizeGitSyncFilePath,
10
+ validateGitSyncFilePath,
11
+ } = require("../lib/cli/git-sync");
8
12
  const { buildSecretReplacements } = require("../lib/server/helpers");
9
13
 
10
14
  // ---------------------------------------------------------------------------
@@ -84,6 +88,7 @@ start options:
84
88
 
85
89
  git-sync options:
86
90
  --message, -m <text> Commit message
91
+ --file, -f <path> Optional file path in .openclaw to sync only one file
87
92
 
88
93
  telegram topic add options:
89
94
  --thread <id> Telegram thread ID
@@ -93,6 +98,7 @@ telegram topic add options:
93
98
 
94
99
  Examples:
95
100
  alphaclaw git-sync --message "sync workspace"
101
+ alphaclaw git-sync --message "update config" --file "workspace/app/config.json"
96
102
  alphaclaw telegram topic add --thread 12 --name "Testing"
97
103
  alphaclaw telegram topic add --thread 12 --name "Testing" --system "Handle QA requests"
98
104
  `);
@@ -234,10 +240,21 @@ const runGitSync = () => {
234
240
  const commitMessage = String(
235
241
  flagValue(commandArgs, "--message", "-m") || "",
236
242
  ).trim();
243
+ const requestedFilePath = String(
244
+ flagValue(commandArgs, "--file", "-f") || "",
245
+ ).trim();
246
+ const normalizedFilePath = normalizeGitSyncFilePath(requestedFilePath);
237
247
  if (!commitMessage) {
238
248
  console.error("[alphaclaw] Missing --message for git-sync");
239
249
  return 1;
240
250
  }
251
+ if (normalizedFilePath) {
252
+ const pathValidation = validateGitSyncFilePath(normalizedFilePath);
253
+ if (!pathValidation.ok) {
254
+ console.error(pathValidation.error);
255
+ return 1;
256
+ }
257
+ }
241
258
  if (!githubToken) {
242
259
  console.error("[alphaclaw] Missing GITHUB_TOKEN for git-sync");
243
260
  return 1;
@@ -312,13 +329,23 @@ const runGitSync = () => {
312
329
  `[alphaclaw] Remote branch "${branch}" not found, skipping pull`,
313
330
  );
314
331
  }
315
- runGit("add -A");
332
+ if (normalizedFilePath) {
333
+ runGit(`add -A -- ${quoteArg(normalizedFilePath)}`);
334
+ } else {
335
+ runGit("add -A");
336
+ }
316
337
  try {
317
338
  runGit("diff --cached --quiet");
318
339
  console.log("[alphaclaw] No changes to commit");
319
340
  return 0;
320
341
  } catch {}
321
- runGit(`commit -m ${quoteArg(commitMessage)}`);
342
+ if (normalizedFilePath) {
343
+ runGit(
344
+ `commit -m ${quoteArg(commitMessage)} -- ${quoteArg(normalizedFilePath)}`,
345
+ );
346
+ } else {
347
+ runGit(`commit -m ${quoteArg(commitMessage)}`);
348
+ }
322
349
  runGit(`push origin ${quoteArg(branch)}`, { withAuth: true });
323
350
  const hash = String(runGit("rev-parse --short HEAD")).trim();
324
351
  console.log(`[alphaclaw] Git sync complete (${hash})`);
@@ -0,0 +1,25 @@
1
+ const normalizeGitSyncFilePath = (requestedFilePath) => {
2
+ const rawPath = String(requestedFilePath || "").trim();
3
+ if (!rawPath) return "";
4
+ return rawPath.replace(/\\/g, "/").replace(/^\.\/+/, "");
5
+ };
6
+
7
+ const validateGitSyncFilePath = (normalizedFilePath) => {
8
+ if (!normalizedFilePath) return { ok: true };
9
+ if (
10
+ normalizedFilePath.startsWith("/") ||
11
+ normalizedFilePath.startsWith("../") ||
12
+ normalizedFilePath.includes("/../")
13
+ ) {
14
+ return {
15
+ ok: false,
16
+ error: "[alphaclaw] --file must stay within /data/.openclaw",
17
+ };
18
+ }
19
+ return { ok: true };
20
+ };
21
+
22
+ module.exports = {
23
+ normalizeGitSyncFilePath,
24
+ validateGitSyncFilePath,
25
+ };