@netnodeag/kraftwerk 0.105.1 → 0.107.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/dist/client/routes.d.ts +2 -0
- package/dist/client/routes.js +2 -0
- package/dist/core/git.d.ts +38 -0
- package/dist/core/git.js +119 -1
- package/dist/core/repos.d.ts +2 -10
- package/dist/core/repos.js +5 -47
- package/dist/core/vibeables.js +12 -9
- package/dist/server/api/git.d.ts +2 -2
- package/dist/server/api/git.js +6 -1
- package/dist/server/api/index.d.ts +3 -2
- package/dist/server/api/workspace.d.ts +2 -0
- package/dist/server/api/workspace.js +3 -0
- package/package.json +1 -1
- package/web/dist/assets/{dist-BUo-wCes.js → dist-0VnFf4le.js} +1 -1
- package/web/dist/assets/{dist-K55rjEIJ.js → dist-9nc4PZkM.js} +1 -1
- package/web/dist/assets/{dist-C4DjPIrd.js → dist-B17zYCGA.js} +1 -1
- package/web/dist/assets/{dist-Dx5saOON.js → dist-BNKzchK0.js} +1 -1
- package/web/dist/assets/{dist-DA2q_iuY.js → dist-BcAObTTF.js} +1 -1
- package/web/dist/assets/{dist-K5WqExa2.js → dist-CfKOEZWA.js} +1 -1
- package/web/dist/assets/{dist-CI324YX1.js → dist-CnwkhXLt.js} +1 -1
- package/web/dist/assets/{dist-BNHxrmw6.js → dist-DkiUAKXo.js} +1 -1
- package/web/dist/assets/{dist-B1XpD1Lm.js → dist-R4d_8TYT.js} +1 -1
- package/web/dist/assets/dist-asNZDDm0.js +1 -0
- package/web/dist/assets/{dist-kDsw_ny_.js → dist-cAilu-a-.js} +1 -1
- package/web/dist/assets/{editor-BTjUXItl.js → editor-TtOHfgtL.js} +3 -3
- package/web/dist/assets/{index-DJGLnVQY.css → index-BWhsUyK0.css} +1 -1
- package/web/dist/assets/{index-CtmT2d2c.js → index-Crt-b1zr.js} +18 -17
- package/web/dist/index.html +2 -2
- package/web/dist/assets/dist-DYeblH_P.js +0 -1
package/dist/client/routes.d.ts
CHANGED
|
@@ -86,8 +86,10 @@ export declare const ROUTES: {
|
|
|
86
86
|
readonly "files.scopes": readonly ["GET", "/api/files"];
|
|
87
87
|
readonly "files.upload": readonly ["POST", "/api/files/upload", "upload"];
|
|
88
88
|
readonly "git.commit": readonly ["POST", "/api/git/commit"];
|
|
89
|
+
readonly "git.commitDiff": readonly ["GET", "/api/git/commits/:hash"];
|
|
89
90
|
readonly "git.diff": readonly ["GET", "/api/git/diff"];
|
|
90
91
|
readonly "git.fetch": readonly ["POST", "/api/git/fetch"];
|
|
92
|
+
readonly "git.log": readonly ["GET", "/api/git/log"];
|
|
91
93
|
readonly "git.pull": readonly ["POST", "/api/git/pull"];
|
|
92
94
|
readonly "git.push": readonly ["POST", "/api/git/push"];
|
|
93
95
|
readonly "git.setupSync": readonly ["POST", "/api/git/sync-setup"];
|
package/dist/client/routes.js
CHANGED
|
@@ -87,8 +87,10 @@ export const ROUTES = {
|
|
|
87
87
|
"files.scopes": ["GET", "/api/files"],
|
|
88
88
|
"files.upload": ["POST", "/api/files/upload", "upload"],
|
|
89
89
|
"git.commit": ["POST", "/api/git/commit"],
|
|
90
|
+
"git.commitDiff": ["GET", "/api/git/commits/:hash"],
|
|
90
91
|
"git.diff": ["GET", "/api/git/diff"],
|
|
91
92
|
"git.fetch": ["POST", "/api/git/fetch"],
|
|
93
|
+
"git.log": ["GET", "/api/git/log"],
|
|
92
94
|
"git.pull": ["POST", "/api/git/pull"],
|
|
93
95
|
"git.push": ["POST", "/api/git/push"],
|
|
94
96
|
"git.setupSync": ["POST", "/api/git/sync-setup"],
|
package/dist/core/git.d.ts
CHANGED
|
@@ -52,6 +52,28 @@ export interface GitFile {
|
|
|
52
52
|
/** Why it cannot be selected, when it cannot. */
|
|
53
53
|
reason?: string;
|
|
54
54
|
}
|
|
55
|
+
/** One commit in a log. */
|
|
56
|
+
export interface GitCommit {
|
|
57
|
+
hash: string;
|
|
58
|
+
short: string;
|
|
59
|
+
subject: string;
|
|
60
|
+
author: string;
|
|
61
|
+
committedAt: string;
|
|
62
|
+
/** On no remote yet: this machine's own work. */
|
|
63
|
+
local: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** The workspace's history: the newest commits that touched its paths, the unpushed ones marked. */
|
|
66
|
+
export interface GitLog {
|
|
67
|
+
commits: GitCommit[];
|
|
68
|
+
error?: string;
|
|
69
|
+
}
|
|
70
|
+
/** One .gitignore: where it is (repo-relative) and its rules — comments and blank lines left out. */
|
|
71
|
+
export interface GitIgnoreFile {
|
|
72
|
+
path: string;
|
|
73
|
+
rules: string[];
|
|
74
|
+
/** Rules left out because the list was capped. */
|
|
75
|
+
more?: number;
|
|
76
|
+
}
|
|
55
77
|
export interface GitStatus {
|
|
56
78
|
enabled: boolean;
|
|
57
79
|
/** Set when the feature is on but the repo cannot be used. */
|
|
@@ -93,6 +115,8 @@ export interface GitStatus {
|
|
|
93
115
|
* someone deletes the copy. Newest first.
|
|
94
116
|
*/
|
|
95
117
|
conflicts?: SyncConflict[];
|
|
118
|
+
/** The repo's .gitignore files with their rules, the root's first: what git leaves out, and so what never syncs. */
|
|
119
|
+
ignores?: GitIgnoreFile[];
|
|
96
120
|
}
|
|
97
121
|
/** One file both sides changed: the remote's version is at `path`, the other side's at `copy`, kept for `by`. */
|
|
98
122
|
export interface SyncConflict {
|
|
@@ -145,6 +169,20 @@ export declare function parseStatus(out: string): {
|
|
|
145
169
|
/** A remote URL fit to show: `https://user:secret@host/x` → `https://host/x`. */
|
|
146
170
|
export declare function withoutCredentials(url: string): string;
|
|
147
171
|
export declare function gitStatus(fresh?: boolean): Promise<GitStatus>;
|
|
172
|
+
/** The newest `n` commits of the repo at `dir` (those touching `pathspecs`, when given), the ones on no remote marked. */
|
|
173
|
+
export declare function commitLog(dir: string, n: number, pathspecs?: string[]): Promise<GitCommit[]>;
|
|
174
|
+
/**
|
|
175
|
+
* One commit as a patch: header, stat, then the diff. The commit's own path
|
|
176
|
+
* list decides what is shown: a path that is not (`hidden` gives the reason
|
|
177
|
+
* — by default a secret or key: a committed key, a renamed-in .env) is left
|
|
178
|
+
* out of both the stat and the patch by pathspec, so no header shape git
|
|
179
|
+
* emits can smuggle it through.
|
|
180
|
+
*/
|
|
181
|
+
export declare function commitPatch(dir: string, hash: string, hidden?: (file: string) => string | undefined): Promise<GitDiff>;
|
|
182
|
+
/** The workspace's history: the newest commits that touched its paths, whoever made them — by hand here, kraftwerk sync, another machine. */
|
|
183
|
+
export declare function gitLog(): Promise<GitLog>;
|
|
184
|
+
/** One commit of the workspace's history as a patch, the files outside the workspace paths (and secrets) left out. */
|
|
185
|
+
export declare function gitCommitDiff(hash: string): Promise<GitDiff>;
|
|
148
186
|
/**
|
|
149
187
|
* Unified diff for one changed file. Reading is as sensitive as writing
|
|
150
188
|
* here: this endpoint has no auth of its own, and a diff of an untracked
|
package/dist/core/git.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { createWriteStream, existsSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { createWriteStream, existsSync, promises as fsp, realpathSync, statSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { boardsRootFor, presentationsRootFor, ENTITY_KINDS, entitiesRootFor, projectsRootFor, reposRootFor, resolveWorkspace, vibeablesRootFor, isSafeGitName } from "../config.js";
|
|
5
5
|
import { ENV_FILE } from "../runner/docker.js";
|
|
@@ -56,6 +56,27 @@ export const DENY = [
|
|
|
56
56
|
/(^|\/)credentials\.json$/,
|
|
57
57
|
];
|
|
58
58
|
const DEFAULTS = { remote: "origin", interval: 300, autosync: "pull" };
|
|
59
|
+
const MAX_IGNORE_FILES = 30;
|
|
60
|
+
const MAX_IGNORE_RULES = 200;
|
|
61
|
+
/** Every .gitignore git itself reads in the repo (tracked or not, none inside an ignored folder), the root's first. */
|
|
62
|
+
async function ignoreFiles(repoRoot) {
|
|
63
|
+
const ls = await git(["ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", ":(glob)**/.gitignore"], repoRoot);
|
|
64
|
+
if (!ls.ok)
|
|
65
|
+
return [];
|
|
66
|
+
const paths = [...new Set(ls.stdout.split("\0").filter(Boolean))].sort((a, b) => a.split("/").length - b.split("/").length || a.localeCompare(b)).slice(0, MAX_IGNORE_FILES);
|
|
67
|
+
const out = [];
|
|
68
|
+
for (const rel of paths) {
|
|
69
|
+
const text = await fsp.readFile(path.join(repoRoot, rel), "utf8").catch(() => null);
|
|
70
|
+
if (text === null)
|
|
71
|
+
continue;
|
|
72
|
+
const rules = text
|
|
73
|
+
.split(/\r?\n/)
|
|
74
|
+
.map((l) => l.trim())
|
|
75
|
+
.filter((l) => l && !l.startsWith("#"));
|
|
76
|
+
out.push({ path: rel, rules: rules.slice(0, MAX_IGNORE_RULES), ...(rules.length > MAX_IGNORE_RULES ? { more: rules.length - MAX_IGNORE_RULES } : {}) });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
59
80
|
/** Local operations are quick; anything touching the network gets longer. */
|
|
60
81
|
const LOCAL_TIMEOUT = 15_000;
|
|
61
82
|
export const NET_TIMEOUT = 60_000;
|
|
@@ -495,6 +516,7 @@ export async function gitStatus(fresh = false) {
|
|
|
495
516
|
? "A configured root points at the repository root, which would put the whole repo in scope. Narrow workflows/knowledge/agents/skills/vibeables/projects in kraftwerk.yml."
|
|
496
517
|
: undefined;
|
|
497
518
|
const conflicts = repo.cfg.autosync === "sync" ? await conflictCopies(repoRoot) : [];
|
|
519
|
+
const ignores = await ignoreFiles(repoRoot);
|
|
498
520
|
const value = {
|
|
499
521
|
...base,
|
|
500
522
|
error: head.error ?? scopeError,
|
|
@@ -502,6 +524,7 @@ export async function gitStatus(fresh = false) {
|
|
|
502
524
|
blockedHidden: blockedHidden || undefined,
|
|
503
525
|
scope: scope.include,
|
|
504
526
|
...(conflicts.length ? { conflicts } : {}),
|
|
527
|
+
...(ignores.length ? { ignores } : {}),
|
|
505
528
|
};
|
|
506
529
|
// A commit that finished while this status was running already emptied
|
|
507
530
|
// the cache; caching the pre-commit list on top of that would show the
|
|
@@ -510,6 +533,101 @@ export async function gitStatus(fresh = false) {
|
|
|
510
533
|
gitState().statusCache = { at: Date.now(), value };
|
|
511
534
|
return value;
|
|
512
535
|
}
|
|
536
|
+
/** The newest `n` commits of the repo at `dir` (those touching `pathspecs`, when given), the ones on no remote marked. */
|
|
537
|
+
export async function commitLog(dir, n, pathspecs = []) {
|
|
538
|
+
const only = pathspecs.length ? ["--", ...pathspecs] : [];
|
|
539
|
+
const [log, local] = await Promise.all([
|
|
540
|
+
git(["log", `-${n}`, "--format=%H%x00%h%x00%s%x00%an%x00%cI", ...only], dir),
|
|
541
|
+
// Bounded like the log: the local commits among the newest N are a prefix of the first N non-remote ones.
|
|
542
|
+
git(["rev-list", "-n", String(n), "HEAD", "--not", "--remotes", ...only], dir),
|
|
543
|
+
]);
|
|
544
|
+
if (!log.ok)
|
|
545
|
+
return [];
|
|
546
|
+
const localSet = new Set(local.ok ? local.stdout.split("\n").map((l) => l.trim()).filter(Boolean) : []);
|
|
547
|
+
return log.stdout
|
|
548
|
+
.split("\n")
|
|
549
|
+
.filter((l) => l.trim())
|
|
550
|
+
.map((l) => {
|
|
551
|
+
const [hash, short, subject, author, committedAt] = l.split("\0");
|
|
552
|
+
return { hash, short, subject, author, committedAt, local: localSet.has(hash) };
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* One commit as a patch: header, stat, then the diff. The commit's own path
|
|
557
|
+
* list decides what is shown: a path that is not (`hidden` gives the reason
|
|
558
|
+
* — by default a secret or key: a committed key, a renamed-in .env) is left
|
|
559
|
+
* out of both the stat and the patch by pathspec, so no header shape git
|
|
560
|
+
* emits can smuggle it through.
|
|
561
|
+
*/
|
|
562
|
+
export async function commitPatch(dir, hash, hidden = (f) => (DENY.some((re) => re.test(f)) ? "secret or key" : undefined)) {
|
|
563
|
+
if (!/^[0-9a-f]{7,40}$/.test(hash))
|
|
564
|
+
return { diff: "", error: "invalid commit" };
|
|
565
|
+
if (!(await git(["rev-parse", "--verify", "-q", `${hash}^{commit}`], dir)).ok)
|
|
566
|
+
return { diff: "", error: "no such commit" };
|
|
567
|
+
// Post-image paths of the commit: "M\0path\0", renames and copies as "R100\0old\0new\0".
|
|
568
|
+
const tree = await git(["diff-tree", "-r", "-M", "-z", "--root", "--name-status", hash], dir);
|
|
569
|
+
if (!tree.ok)
|
|
570
|
+
return { diff: "", error: tree.stderr || "git diff-tree failed" };
|
|
571
|
+
const parts = tree.stdout.split("\0");
|
|
572
|
+
const paths = [];
|
|
573
|
+
for (let i = 0; i < parts.length; i++) {
|
|
574
|
+
const status = parts[i];
|
|
575
|
+
if (!status || /^[0-9a-f]{40}$/.test(status))
|
|
576
|
+
continue; // the leading hash line of --root
|
|
577
|
+
const two = /^[RC]/.test(status);
|
|
578
|
+
const file = two ? parts[i + 2] : parts[i + 1];
|
|
579
|
+
if (file)
|
|
580
|
+
paths.push(file);
|
|
581
|
+
i += two ? 2 : 1;
|
|
582
|
+
}
|
|
583
|
+
const kept = paths.filter((f) => !hidden(f));
|
|
584
|
+
// "(2 files not shown: secret or key)" — one line per reason.
|
|
585
|
+
const reasons = new Map();
|
|
586
|
+
for (const f of paths) {
|
|
587
|
+
const why = hidden(f);
|
|
588
|
+
if (why)
|
|
589
|
+
reasons.set(why, (reasons.get(why) ?? 0) + 1);
|
|
590
|
+
}
|
|
591
|
+
const notes = [...reasons].map(([why, count]) => `\n(${count} file${count === 1 ? "" : "s"} not shown: ${why})\n`).join("");
|
|
592
|
+
const format = "--format=commit %H%nAuthor: %an <%ae>%nDate: %cI%n%n %s%n";
|
|
593
|
+
if (kept.length === 0 && paths.length > 0) {
|
|
594
|
+
const head = await git(["show", "--no-patch", format, hash], dir);
|
|
595
|
+
return { diff: `${head.stdout}${notes}` };
|
|
596
|
+
}
|
|
597
|
+
const r = await git(["show", "--stat", "--patch", format, hash, "--", ...kept.map(literal)], dir);
|
|
598
|
+
if (!r.ok)
|
|
599
|
+
return { diff: "", error: r.stderr || "git show failed" };
|
|
600
|
+
const out = capDiff(r.stdout);
|
|
601
|
+
out.diff += notes;
|
|
602
|
+
return out;
|
|
603
|
+
}
|
|
604
|
+
const LOG_COMMITS = 50;
|
|
605
|
+
/** The workspace paths as pathspecs — none when a root is the whole repo. */
|
|
606
|
+
const scopeSpecs = (scope) => (scope.wholeRepo || scope.include.includes(".") ? [] : scope.include.map(literal));
|
|
607
|
+
/** Why a committed path is not shown in the workspace's history, or undefined when it is: the status list's rule, for a path that is history already. */
|
|
608
|
+
const hiddenIn = (scope) => (file) => DENY.some((re) => re.test(file))
|
|
609
|
+
? "secret or key"
|
|
610
|
+
: scope.exclude.some((e) => within(file, e)) || !(scope.wholeRepo || scope.include.includes(".") || scope.include.some((r) => within(file, r)))
|
|
611
|
+
? "outside the workspace paths"
|
|
612
|
+
: undefined;
|
|
613
|
+
/** The workspace's history: the newest commits that touched its paths, whoever made them — by hand here, kraftwerk sync, another machine. */
|
|
614
|
+
export async function gitLog() {
|
|
615
|
+
const opened = await openRepo();
|
|
616
|
+
if (opened.off)
|
|
617
|
+
return { commits: [], error: "git sync is off" };
|
|
618
|
+
if (!opened.repo)
|
|
619
|
+
return { commits: [], error: opened.error ?? "not a git repository" };
|
|
620
|
+
return { commits: await commitLog(opened.repo.repoRoot, LOG_COMMITS, scopeSpecs(scopeFor(opened.repo))) };
|
|
621
|
+
}
|
|
622
|
+
/** One commit of the workspace's history as a patch, the files outside the workspace paths (and secrets) left out. */
|
|
623
|
+
export async function gitCommitDiff(hash) {
|
|
624
|
+
const opened = await openRepo();
|
|
625
|
+
if (opened.off)
|
|
626
|
+
return { diff: "", error: "git sync is off" };
|
|
627
|
+
if (!opened.repo)
|
|
628
|
+
return { diff: "", error: opened.error ?? "not a git repository" };
|
|
629
|
+
return commitPatch(opened.repo.repoRoot, hash, hiddenIn(scopeFor(opened.repo)));
|
|
630
|
+
}
|
|
513
631
|
/**
|
|
514
632
|
* Unified diff for one changed file. Reading is as sensitive as writing
|
|
515
633
|
* here: this endpoint has no auth of its own, and a diff of an untracked
|
package/dist/core/repos.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ResolvedWorkspace } from "../config.js";
|
|
2
|
-
import { type GitDiff } from "./git.js";
|
|
2
|
+
import { type GitCommit, type GitDiff } from "./git.js";
|
|
3
3
|
/**
|
|
4
4
|
* Repositories: the git clones an agent works on, kept under one root
|
|
5
5
|
* inside the project (`repos.root` in kraftwerk.yml, default repos/). The
|
|
@@ -51,15 +51,7 @@ export interface RepoFile {
|
|
|
51
51
|
/** modified, added, deleted, renamed, untracked, conflicted. */
|
|
52
52
|
status: string;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
55
|
-
hash: string;
|
|
56
|
-
short: string;
|
|
57
|
-
subject: string;
|
|
58
|
-
author: string;
|
|
59
|
-
committedAt: string;
|
|
60
|
-
/** On no remote yet: the clone's own work. */
|
|
61
|
-
local: boolean;
|
|
62
|
-
}
|
|
54
|
+
export type RepoCommit = GitCommit;
|
|
63
55
|
/**
|
|
64
56
|
* The detail page's view of a clone: the listing's summary plus what is
|
|
65
57
|
* happening inside — changed files, line counts against HEAD, the recent
|
package/dist/core/repos.js
CHANGED
|
@@ -4,7 +4,7 @@ import { gitignoreHas, ignoreEntryFor, reposRootFor, resolveWorkspace } from "..
|
|
|
4
4
|
import { workspaceRoot } from "./context.js";
|
|
5
5
|
import { moveToTrash } from "./trash.js";
|
|
6
6
|
import { newestMtime } from "./mtime.js";
|
|
7
|
-
import {
|
|
7
|
+
import { commitLog, commitPatch, DENY, diffAgainstHead, git, gitNet, label, literal, parseStatus, sshCommandFor } from "./git.js";
|
|
8
8
|
/**
|
|
9
9
|
* A clone is the one call here that can legitimately take long: a large
|
|
10
10
|
* repository on a slow link is minutes, not seconds. Prompts are already
|
|
@@ -140,26 +140,15 @@ export async function repoDetail(slug) {
|
|
|
140
140
|
const detail = { ...info, files: [], commits: [], insertions: 0, deletions: 0 };
|
|
141
141
|
if (info.error)
|
|
142
142
|
return detail;
|
|
143
|
-
const [status,
|
|
143
|
+
const [status, commits, stat, upstream] = await Promise.all([
|
|
144
144
|
git(["status", "--porcelain=v1", "-z", "--untracked-files=all"], dir),
|
|
145
|
-
|
|
146
|
-
// Bounded like the log: the local commits among the newest N are a prefix of the first N non-remote ones.
|
|
147
|
-
git(["rev-list", `-n`, String(COMMITS), "HEAD", "--not", "--remotes"], dir),
|
|
145
|
+
commitLog(dir, COMMITS),
|
|
148
146
|
git(["diff", "HEAD", "--shortstat"], dir),
|
|
149
147
|
git(["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"], dir),
|
|
150
148
|
]);
|
|
151
149
|
if (status.ok)
|
|
152
150
|
detail.files = parseStatus(status.stdout).map((f) => ({ path: f.path, code: f.code, status: label(f.code) }));
|
|
153
|
-
|
|
154
|
-
const localSet = new Set(local.ok ? local.stdout.split("\n").map((l) => l.trim()).filter(Boolean) : []);
|
|
155
|
-
detail.commits = log.stdout
|
|
156
|
-
.split("\n")
|
|
157
|
-
.filter((l) => l.trim())
|
|
158
|
-
.map((l) => {
|
|
159
|
-
const [hash, short, subject, author, committedAt] = l.split("\0");
|
|
160
|
-
return { hash, short, subject, author, committedAt, local: localSet.has(hash) };
|
|
161
|
-
});
|
|
162
|
-
}
|
|
151
|
+
detail.commits = commits;
|
|
163
152
|
if (stat.ok) {
|
|
164
153
|
const ins = /(\d+) insertion/.exec(stat.stdout);
|
|
165
154
|
const del = /(\d+) deletion/.exec(stat.stdout);
|
|
@@ -198,38 +187,7 @@ export async function repoCommitDiff(slug, hash) {
|
|
|
198
187
|
if (!/^[0-9a-f]{7,40}$/.test(hash))
|
|
199
188
|
return { diff: "", error: "invalid commit" };
|
|
200
189
|
const { dir } = await cloneDir(slug);
|
|
201
|
-
|
|
202
|
-
return { diff: "", error: "no such commit" };
|
|
203
|
-
// Post-image paths of the commit: "M\0path\0", renames and copies as "R100\0old\0new\0".
|
|
204
|
-
const tree = await git(["diff-tree", "-r", "-M", "-z", "--root", "--name-status", hash], dir);
|
|
205
|
-
if (!tree.ok)
|
|
206
|
-
return { diff: "", error: tree.stderr || "git diff-tree failed" };
|
|
207
|
-
const parts = tree.stdout.split("\0");
|
|
208
|
-
const paths = [];
|
|
209
|
-
for (let i = 0; i < parts.length; i++) {
|
|
210
|
-
const status = parts[i];
|
|
211
|
-
if (!status || /^[0-9a-f]{40}$/.test(status))
|
|
212
|
-
continue; // the leading hash line of --root
|
|
213
|
-
const two = /^[RC]/.test(status);
|
|
214
|
-
const file = two ? parts[i + 2] : parts[i + 1];
|
|
215
|
-
if (file)
|
|
216
|
-
paths.push(file);
|
|
217
|
-
i += two ? 2 : 1;
|
|
218
|
-
}
|
|
219
|
-
const kept = paths.filter((f) => !DENY.some((re) => re.test(f)));
|
|
220
|
-
const hidden = paths.length - kept.length;
|
|
221
|
-
const format = "--format=commit %H%nAuthor: %an <%ae>%nDate: %cI%n%n %s%n";
|
|
222
|
-
if (kept.length === 0 && paths.length > 0) {
|
|
223
|
-
const head = await git(["show", "--no-patch", format, hash], dir);
|
|
224
|
-
return { diff: `${head.stdout}\n(${hidden} file${hidden === 1 ? "" : "s"} not shown: secret or key)\n` };
|
|
225
|
-
}
|
|
226
|
-
const r = await git(["show", "--stat", "--patch", format, hash, "--", ...kept.map(literal)], dir);
|
|
227
|
-
if (!r.ok)
|
|
228
|
-
return { diff: "", error: r.stderr || "git show failed" };
|
|
229
|
-
const out = capDiff(r.stdout);
|
|
230
|
-
if (hidden > 0)
|
|
231
|
-
out.diff += `\n(${hidden} file${hidden === 1 ? "" : "s"} not shown: secret or key)\n`;
|
|
232
|
-
return out;
|
|
190
|
+
return commitPatch(dir, hash);
|
|
233
191
|
}
|
|
234
192
|
/** Every clone under the root, alphabetically. Folders without .git are skipped. */
|
|
235
193
|
export async function listRepos() {
|
package/dist/core/vibeables.js
CHANGED
|
@@ -205,10 +205,13 @@ const IGNORED = /(^|[\\/])(\.git|node_modules|\.cache|\.vite|\.next)([\\/]|$)/;
|
|
|
205
205
|
* where it cannot watch, the pane still has its manual reload.
|
|
206
206
|
*/
|
|
207
207
|
export function subscribeVibeable(slug, dir, fn) {
|
|
208
|
-
|
|
208
|
+
// The workspace's channels, taken now: the watcher's callbacks and the returned unsubscribe run
|
|
209
|
+
// later, outside the request (a closed connection, a file event), where no workspace is current.
|
|
210
|
+
const all = channels();
|
|
211
|
+
let ch = all.get(slug);
|
|
209
212
|
if (!ch) {
|
|
210
213
|
ch = { watcher: null, subs: new Set(), pending: new Set(), timer: null };
|
|
211
|
-
|
|
214
|
+
all.set(slug, ch);
|
|
212
215
|
const c = ch;
|
|
213
216
|
try {
|
|
214
217
|
c.watcher = watch(dir, { recursive: true, persistent: false }, (_event, filename) => {
|
|
@@ -231,18 +234,18 @@ export function subscribeVibeable(slug, dir, fn) {
|
|
|
231
234
|
s({ type: "error", message: `file watcher stopped: ${err.message}` });
|
|
232
235
|
// Drop the channel: the next subscriber gets a fresh watch() attempt
|
|
233
236
|
// instead of joining a dead one that never reports anything.
|
|
234
|
-
dropChannel(slug);
|
|
237
|
+
dropChannel(slug, all);
|
|
235
238
|
});
|
|
236
239
|
}
|
|
237
240
|
catch (err) {
|
|
238
|
-
dropChannel(slug);
|
|
241
|
+
dropChannel(slug, all);
|
|
239
242
|
queueMicrotask(() => fn({ type: "error", message: `cannot watch ${dir}: ${err.message}` }));
|
|
240
243
|
return () => { };
|
|
241
244
|
}
|
|
242
245
|
}
|
|
243
246
|
ch.subs.add(fn);
|
|
244
247
|
return () => {
|
|
245
|
-
const c =
|
|
248
|
+
const c = all.get(slug);
|
|
246
249
|
if (!c)
|
|
247
250
|
return;
|
|
248
251
|
c.subs.delete(fn);
|
|
@@ -250,19 +253,19 @@ export function subscribeVibeable(slug, dir, fn) {
|
|
|
250
253
|
if (c.timer)
|
|
251
254
|
clearTimeout(c.timer);
|
|
252
255
|
c.watcher?.close();
|
|
253
|
-
|
|
256
|
+
all.delete(slug);
|
|
254
257
|
}
|
|
255
258
|
};
|
|
256
259
|
}
|
|
257
260
|
/** Close a channel's watcher and forget it; subscribers are left to reconnect. */
|
|
258
|
-
function dropChannel(slug) {
|
|
259
|
-
const c =
|
|
261
|
+
function dropChannel(slug, all = channels()) {
|
|
262
|
+
const c = all.get(slug);
|
|
260
263
|
if (!c)
|
|
261
264
|
return;
|
|
262
265
|
if (c.timer)
|
|
263
266
|
clearTimeout(c.timer);
|
|
264
267
|
c.watcher?.close();
|
|
265
|
-
|
|
268
|
+
all.delete(slug);
|
|
266
269
|
}
|
|
267
270
|
function broadcast(slug, ev) {
|
|
268
271
|
const c = channels().get(slug);
|
package/dist/server/api/git.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export declare const gitRoutes: (import("./router.js").Route<"git.commit", impor
|
|
|
8
8
|
}>, "/api/git/commit", z.ZodObject<{
|
|
9
9
|
paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
10
10
|
message: z.ZodDefault<z.ZodString>;
|
|
11
|
-
}, z.core.$strip>> | import("./router.js").Route<"git.diff", import("../../core/git.js").GitDiff, "/api/git/diff", undefined> | import("./router.js").Route<"git.fetch", import("./router.js").Reply<{
|
|
11
|
+
}, z.core.$strip>> | import("./router.js").Route<"git.commitDiff", import("./router.js").Reply<import("../../core/git.js").GitDiff>, "/api/git/commits/:hash", undefined> | import("./router.js").Route<"git.diff", import("../../core/git.js").GitDiff, "/api/git/diff", undefined> | import("./router.js").Route<"git.fetch", import("./router.js").Reply<{
|
|
12
12
|
ok: boolean;
|
|
13
13
|
error?: string;
|
|
14
|
-
}>, "/api/git/fetch", undefined> | import("./router.js").Route<"git.pull", import("./router.js").Reply<{
|
|
14
|
+
}>, "/api/git/fetch", undefined> | import("./router.js").Route<"git.log", import("../../core/git.js").GitLog, "/api/git/log", undefined> | import("./router.js").Route<"git.pull", import("./router.js").Reply<{
|
|
15
15
|
ok: boolean;
|
|
16
16
|
error?: string;
|
|
17
17
|
}>, "/api/git/pull", undefined> | import("./router.js").Route<"git.push", import("./router.js").Reply<{
|
package/dist/server/api/git.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { resolveWorkspace } from "../../config.js";
|
|
3
3
|
import { workspaceRoot } from "../../core/context.js";
|
|
4
|
-
import { gitCommit, gitDiff, gitFetch, gitPull, gitPush, gitStatus } from "../../core/git.js";
|
|
4
|
+
import { gitCommit, gitCommitDiff, gitDiff, gitFetch, gitLog, gitPull, gitPush, gitStatus } from "../../core/git.js";
|
|
5
5
|
import { hostingFor } from "../cloud.js";
|
|
6
6
|
import { setupSync } from "../sync-setup.js";
|
|
7
7
|
import { addRepo, listRepos, openRepos, removeRepo, repoCommitDiff, repoDetail, repoDiff, updateRepo } from "../../core/repos.js";
|
|
@@ -29,6 +29,11 @@ export const gitRoutes = [
|
|
|
29
29
|
fail(400, "path required");
|
|
30
30
|
return gitDiff(file);
|
|
31
31
|
}),
|
|
32
|
+
route({ name: "git.log", method: "GET", path: "/api/git/log", summary: "the newest commits that touched the workspace paths, unpushed marked" }, async () => gitLog()),
|
|
33
|
+
route({ name: "git.commitDiff", method: "GET", path: "/api/git/commits/:hash", summary: "one commit as a patch, the workspace paths only", errors: 400 }, async (c) => {
|
|
34
|
+
const d = await gitCommitDiff(c.params.hash);
|
|
35
|
+
return reply(d.error ? (/^no such commit/.test(d.error) ? 404 : 400) : 200, d);
|
|
36
|
+
}),
|
|
32
37
|
// Committing stays manual: the background timer never writes history, and pushes it only with `autosync: push`.
|
|
33
38
|
route({ name: "git.commit", method: "POST", path: "/api/git/commit", summary: "stage and commit {paths, message}", errors: 400, body: Commit }, async (c) => {
|
|
34
39
|
const { paths, message } = await c.body();
|
|
@@ -539,10 +539,10 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
539
539
|
}>, "/api/git/commit", z.ZodObject<{
|
|
540
540
|
paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
541
541
|
message: z.ZodDefault<z.ZodString>;
|
|
542
|
-
}, z.core.$strip>> | Route<"git.diff", import("../../core/git.js").GitDiff, "/api/git/diff", undefined> | Route<"git.fetch", import("./router.js").Reply<{
|
|
542
|
+
}, z.core.$strip>> | Route<"git.commitDiff", import("./router.js").Reply<import("../../core/git.js").GitDiff>, "/api/git/commits/:hash", undefined> | Route<"git.diff", import("../../core/git.js").GitDiff, "/api/git/diff", undefined> | Route<"git.fetch", import("./router.js").Reply<{
|
|
543
543
|
ok: boolean;
|
|
544
544
|
error?: string;
|
|
545
|
-
}>, "/api/git/fetch", undefined> | Route<"git.pull", import("./router.js").Reply<{
|
|
545
|
+
}>, "/api/git/fetch", undefined> | Route<"git.log", import("../../core/git.js").GitLog, "/api/git/log", undefined> | Route<"git.pull", import("./router.js").Reply<{
|
|
546
546
|
ok: boolean;
|
|
547
547
|
error?: string;
|
|
548
548
|
}>, "/api/git/pull", undefined> | Route<"git.push", import("./router.js").Reply<{
|
|
@@ -616,6 +616,7 @@ export declare const routes: (Route<"agents.addJournal", {
|
|
|
616
616
|
signedIn: boolean;
|
|
617
617
|
role?: "member" | "owner" | undefined;
|
|
618
618
|
via: "device" | "local" | "member";
|
|
619
|
+
runsIn: "cloud" | "machine";
|
|
619
620
|
}, "/api/me", undefined> | Route<"meta.get", {
|
|
620
621
|
workspaceName: string;
|
|
621
622
|
workspaceSlug: string;
|
|
@@ -22,6 +22,8 @@ export declare const workspaceRoutes: (import("./router.js").Route<"identity.get
|
|
|
22
22
|
role?: "member" | "owner" | undefined;
|
|
23
23
|
/** How the signed-in person got here: through the relay as a member, or on this machine. */
|
|
24
24
|
via: "device" | "local" | "member";
|
|
25
|
+
/** Where this workspace runs: in a sandbox kraftwerk cloud started for it, or on somebody's machine. */
|
|
26
|
+
runsIn: "cloud" | "machine";
|
|
25
27
|
}, "/api/me", undefined> | import("./router.js").Route<"meta.get", {
|
|
26
28
|
workspaceName: string;
|
|
27
29
|
workspaceSlug: string;
|
|
@@ -14,6 +14,7 @@ import { disposeAllDevs } from "../../core/vibeables.js";
|
|
|
14
14
|
import { identityString, readIdentity } from "../../core/identity.js";
|
|
15
15
|
import { currentPerson, humanActor } from "../../core/person.js";
|
|
16
16
|
import { fail, reply, route } from "./router.js";
|
|
17
|
+
import { sandboxOrigin } from "../sandbox.js";
|
|
17
18
|
/** A feature block with a folder (repos, vibeables, projects); saveSettings checks the root. Nested blocks are plain objects: saveSettings reads only these fields. */
|
|
18
19
|
const RootBlock = z.object({ enabled: z.boolean(), root: z.string().optional() });
|
|
19
20
|
/** The UI-editable subset of kraftwerk.yml. Loose: saveSettings validates values and writes what it knows. */
|
|
@@ -144,6 +145,8 @@ export const workspaceRoutes = [
|
|
|
144
145
|
...(signedIn && c.trust.kind === "local" ? { role: c.trust.user.role } : {}),
|
|
145
146
|
/** How the signed-in person got here: through the relay as a member, or on this machine. */
|
|
146
147
|
via: c.trust.kind === "member" ? "member" : c.trust.kind === "device" ? "device" : "local",
|
|
148
|
+
/** Where this workspace runs: in a sandbox kraftwerk cloud started for it, or on somebody's machine. */
|
|
149
|
+
runsIn: sandboxOrigin() ? "cloud" : "machine",
|
|
147
150
|
};
|
|
148
151
|
}),
|
|
149
152
|
route({ name: "settings.get", method: "GET", path: "/api/settings", summary: "kraftwerk.yml, parsed, with resolved paths" }, async () => getSettings()),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netnodeag/kraftwerk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.107.0",
|
|
4
4
|
"description": "Open-source agentic workspace for teams — where people and AI agents get work done together: agents (Claude Code, Codex, Pi), skills, shared knowledge, repeatable workflows, and deterministic verification",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e,R as t,Ut as n,n as r,r as i,s as a,u as o}from"./dist-BUzdcj0Z.js";import{n as s}from"./dist-
|
|
1
|
+
import{L as e,R as t,Ut as n,n as r,r as i,s as a,u as o}from"./dist-BUzdcj0Z.js";import{n as s}from"./dist-R4d_8TYT.js";import{r as c}from"./dist-cAilu-a-.js";var l=1,u=33,d=34,f=35,p=36,m=new r(e=>{let t=e.pos;for(;;){if(e.next==10){e.advance();break}if(e.next==123&&e.peek(1)==123||e.next<0)break;e.advance()}e.pos>t&&e.acceptToken(l)});function h(e,t,n){return new r(r=>{let i=r.pos;for(;r.next!=e&&r.next>=0&&(n||r.next!=38&&(r.next!=123||r.peek(1)!=123));)r.advance();r.pos>i&&r.acceptToken(t)})}var g=h(39,u,!1),_=h(34,d,!1),v=h(39,f,!0),y=h(34,p,!0),b=i.deserialize({version:14,states:"(jOVOqOOOeQpOOOvO!bO'#CaOOOP'#Cx'#CxQVOqOOO!OQpO'#CfO!WQpO'#ClO!]QpO'#CrO!bQpO'#CsOOQO'#Cv'#CvQ!gQpOOQ!lQpOOQ!qQpOOOOOV,58{,58{O!vOpO,58{OOOP-E6v-E6vO!{QpO,59QO#TQpO,59QOOQO,59W,59WO#YQpO,59^OOQO,59_,59_O#_QpOOO#_QpOOO#gQpOOOOOV1G.g1G.gO#oQpO'#CyO#tQpO1G.lOOQO1G.l1G.lO#|QpO1G.lOOQO1G.x1G.xO$UO`O'#DUO$ZOWO'#DUOOQO'#Co'#CoQOQpOOOOQO'#Cu'#CuO$`OtO'#CwO$qOrO'#CwOOQO,59e,59eOOQO-E6w-E6wOOQO7+$W7+$WO%SQpO7+$WO%[QpO7+$WOOOO'#Cp'#CpO%aOpO,59pOOOO'#Cq'#CqO%fOpO,59pOOOS'#Cz'#CzO%kOtO,59cOOQO,59c,59cOOOQ'#C{'#C{O%|OrO,59cO&_QpO<<GrOOQO<<Gr<<GrOOQO1G/[1G/[OOOS-E6x-E6xOOQO1G.}1G.}OOOQ-E6y-E6yOOQOAN=^AN=^",stateData:"&d~OvOS~OPROSQOVROWRO~OZTO[XO^VOaUOhWO~OR]OU^O~O[`O^aO~O[bO~O[cO~O[dO~ObeO~ObfO~ObgO~ORhO~O]kOwiO~O[lO~O_mO~OynOzoO~OysOztO~O[uO~O]wOwiO~O_yOwiO~OtzO~Os|O~OSQOV!OOW!OOr!OOy!QO~OSQOV!ROW!ROq!ROz!QO~O_!TOwiO~O]!UO~Oy!VO~Oz!VO~OSQOV!OOW!OOr!OOy!XO~OSQOV!ROW!ROq!ROz!XO~O]!ZO~O",goto:"#dyPPPPPzPPPP!WPPPPP!WPP!Z!^!a!d!dP!g!j!m!p!v#Q#WPPPPPPPP#^SROSS!Os!PT!Rt!SRYPRqeR{nR}oRZPRqfR[PRqgQSOR_SQj`SvjxRxlQ!PsR!W!PQ!StR!Y!SQpeRrf",nodeNames:`⚠ Text Content }} {{ Interpolation InterpolationContent Entity InvalidEntity Attribute BoundAttributeName [ Identifier ] ( ) ReferenceName # Is ExpressionAttributeValue AttributeInterpolation AttributeInterpolation EventName DirectiveName * StatementAttributeValue AttributeName AttributeValue`,maxTerm:42,nodeProps:[[`openedBy`,3,`{{`,15,`(`],[`closedBy`,4,`}}`,14,`)`],[`isolate`,-4,5,19,25,27,``]],skippedNodes:[0],repeatNodeCount:4,tokenData:"0r~RyOX#rXY$mYZ$mZ]#r]^$m^p#rpq$mqr#rrs%jst&Qtv#rvw&hwx)zxy*byz*xz{+`{}#r}!O+v!O!P-]!P!Q#r!Q![+v![!]+v!]!_#r!_!`-s!`!c#r!c!}+v!}#O.Z#O#P#r#P#Q.q#Q#R#r#R#S+v#S#T#r#T#o+v#o#p/X#p#q#r#q#r0Z#r%W#r%W;'S+v;'S;:j-V;:j;=`$g<%lO+vQ#wTUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rQ$ZSO#q#r#r;'S#r;'S;=`$g<%lO#rQ$jP;=`<%l#rR$t[UQvPOX#rXY$mYZ$mZ]#r]^$m^p#rpq$mq#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR%qTyPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR&XTaPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR&oXUQWPOp'[pq#rq!]'[!]!^#r!^#q'[#q#r(d#r;'S'[;'S;=`)t<%lO'[R'aXUQOp'[pq#rq!]'[!]!^'|!^#q'[#q#r(d#r;'S'[;'S;=`)t<%lO'[R(TTVPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR(gXOp'[pq#rq!]'[!]!^'|!^#q'[#q#r)S#r;'S'[;'S;=`)t<%lO'[P)VUOp)Sq!])S!]!^)i!^;'S)S;'S;=`)n<%lO)SP)nOVPP)qP;=`<%l)SR)wP;=`<%l'[R*RTzPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR*iT^PUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR+PT_PUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR+gThPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR+}b[PUQO}#r}!O+v!O!Q#r!Q![+v![!]+v!]!c#r!c!}+v!}#R#r#R#S+v#S#T#r#T#o+v#o#q#r#q#r$W#r%W#r%W;'S+v;'S;:j-V;:j;=`$g<%lO+vR-YP;=`<%l+vR-dTwPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR-zTUQbPO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR.bTZPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR.xT]PUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR/^VUQO#o#r#o#p/s#p#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#rR/zTSPUQO#q#r#q#r$W#r;'S#r;'S;=`$g<%lO#r~0^TO#q#r#q#r0m#r;'S#r;'S;=`$g<%lO#r~0rOR~",tokenizers:[m,g,_,v,y,0,1],topRules:{Content:[0,2],Attribute:[1,9]},tokenPrec:0}),x=c.parser.configure({top:`SingleExpression`}),S=b.configure({props:[e({Text:t.content,Is:t.definitionOperator,AttributeName:t.attributeName,"AttributeValue ExpressionAttributeValue StatementAttributeValue":t.attributeValue,Entity:t.character,InvalidEntity:t.invalid,"BoundAttributeName/Identifier":t.attributeName,"EventName/Identifier":t.special(t.attributeName),"ReferenceName/Identifier":t.variableName,"DirectiveName/Identifier":t.keyword,"{{ }}":t.brace,"( )":t.paren,"[ ]":t.bracket,"# '*'":t.punctuation})]}),C={parser:x},w={parser:c.parser},T=S.configure({wrap:n((e,t)=>e.name==`InterpolationContent`?C:null)}),E=S.configure({wrap:n((e,t)=>e.name==`InterpolationContent`?C:e.name==`AttributeInterpolation`?e.node.parent?.name==`StatementAttributeValue`?w:C:null),top:`Attribute`}),D={parser:T},O={parser:E},k=s({selfClosingTags:!0});function A(e){return e.configure({wrap:n(M)},`angular`)}var j=A(k.language);function M(e,t){switch(e.name){case`Attribute`:return/^[*#(\[]|\{\{/.test(t.read(e.from,e.to))?O:null;case`Text`:return D}return null}function N(e={}){let t=k;if(e.base){if(e.base.language.name!=`html`||!(e.base.language instanceof a))throw RangeError(`The base option must be the result of calling html(...)`);t=e.base}return new o(t.language==k.language?j:A(t.language),[t.support,t.language.data.of({closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/})])}export{N as angular};
|