pi-gentic 0.1.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/README.md +499 -0
- package/dist/commands.d.ts +93 -0
- package/dist/commands.js +422 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.js +407 -0
- package/dist/core.d.ts +19 -0
- package/dist/core.js +125 -0
- package/dist/extension.d.ts +2 -0
- package/dist/extension.js +476 -0
- package/dist/orchestrator.d.ts +277 -0
- package/dist/orchestrator.js +633 -0
- package/dist/policy.d.ts +43 -0
- package/dist/policy.js +136 -0
- package/dist/prompt.d.ts +12 -0
- package/dist/prompt.js +226 -0
- package/dist/runs.d.ts +99 -0
- package/dist/runs.js +540 -0
- package/dist/runtime.d.ts +127 -0
- package/dist/runtime.js +360 -0
- package/dist/sessions.d.ts +56 -0
- package/dist/sessions.js +487 -0
- package/dist/ui.d.ts +108 -0
- package/dist/ui.js +957 -0
- package/dist/worktrees.d.ts +1 -0
- package/dist/worktrees.js +86 -0
- package/docs/assets/error-card.png +0 -0
- package/docs/assets/load-agent.png +0 -0
- package/docs/assets/orchestration-tree.png +0 -0
- package/docs/assets/send-background.png +0 -0
- package/docs/assets/send-foreground.png +0 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prepareWorktree({ repoCwd, repo, cwd, worktree, message, }: AnyRecord): Promise<string>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git worktree preparation for delegated agent sessions.
|
|
3
|
+
*
|
|
4
|
+
* The agents tool treats cwd as the worktree folder when worktree is set.
|
|
5
|
+
* The repo option selects the source repository for that worktree.
|
|
6
|
+
*/
|
|
7
|
+
import { execFile } from "node:child_process";
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { promisify } from "node:util";
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
12
|
+
export async function prepareWorktree({ repoCwd, repo, cwd, worktree, message, }) {
|
|
13
|
+
const repoRoot = await repositoryRoot(repoCwd, repo);
|
|
14
|
+
const branchInput = stringOrUndefined(worktree);
|
|
15
|
+
const fallbackName = worktreeSlug(branchInput ?? stringOrUndefined(cwd) ?? stringOrUndefined(message));
|
|
16
|
+
const worktreePath = path.resolve(repoRoot, cwd
|
|
17
|
+
? String(cwd)
|
|
18
|
+
: path.join(".agentfiles", "worktrees", fallbackName));
|
|
19
|
+
const branch = gitBranchName(branchInput ?? path.basename(worktreePath) ?? fallbackName);
|
|
20
|
+
await ensureGitWorktree(repoRoot, worktreePath, branch);
|
|
21
|
+
return worktreePath;
|
|
22
|
+
}
|
|
23
|
+
async function repositoryRoot(repoCwd, repo) {
|
|
24
|
+
const base = String(repoCwd || process.cwd());
|
|
25
|
+
const source = stringOrUndefined(repo);
|
|
26
|
+
const repositoryPath = source ? path.resolve(base, source) : base;
|
|
27
|
+
try {
|
|
28
|
+
return await gitOutput(repositoryPath, ["rev-parse", "--show-toplevel"]);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new Error(`Worktree repository must be a git repository: ${repositoryPath}`, { cause: error });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function ensureGitWorktree(repoRoot, worktreePath, branch) {
|
|
35
|
+
if (existsSync(path.join(worktreePath, ".git")))
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
await gitOutput(repoRoot, ["worktree", "add", worktreePath, branch]);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
await gitOutput(repoRoot, [
|
|
42
|
+
"worktree",
|
|
43
|
+
"add",
|
|
44
|
+
"-b",
|
|
45
|
+
branch,
|
|
46
|
+
worktreePath,
|
|
47
|
+
"HEAD",
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function gitOutput(cwd, args) {
|
|
52
|
+
const { stdout } = await execFileAsync("git", args, {
|
|
53
|
+
cwd,
|
|
54
|
+
timeout: 30_000,
|
|
55
|
+
windowsHide: true,
|
|
56
|
+
});
|
|
57
|
+
return stdout.trim();
|
|
58
|
+
}
|
|
59
|
+
function stringOrUndefined(value) {
|
|
60
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
61
|
+
}
|
|
62
|
+
function worktreeSlug(value) {
|
|
63
|
+
const source = String(value ?? "agent-worktree");
|
|
64
|
+
const base = source
|
|
65
|
+
.toLowerCase()
|
|
66
|
+
.replace(/[^a-z0-9._/-]+/g, "-")
|
|
67
|
+
.replace(/^-+|-+$/g, "")
|
|
68
|
+
.slice(0, 60);
|
|
69
|
+
return `${base || "agent-worktree"}-${hashText(source)}`;
|
|
70
|
+
}
|
|
71
|
+
function gitBranchName(value) {
|
|
72
|
+
return (String(value ?? "agent-worktree")
|
|
73
|
+
.replace(/\\/g, "/")
|
|
74
|
+
.split("/")
|
|
75
|
+
.map((part) => part
|
|
76
|
+
.replace(/[^A-Za-z0-9._-]+/g, "-")
|
|
77
|
+
.replace(/^[-.]+|[-.]+$/g, ""))
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.join("/") || "agent-worktree");
|
|
80
|
+
}
|
|
81
|
+
function hashText(value) {
|
|
82
|
+
let hash = 5381;
|
|
83
|
+
for (const char of value)
|
|
84
|
+
hash = ((hash << 5) + hash) ^ char.charCodeAt(0);
|
|
85
|
+
return Math.abs(hash >>> 0).toString(36).slice(0, 6);
|
|
86
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-gentic",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Pi extension for orchestrating durable agent sessions, delegation, and worktrees.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/CodeByPeete/pi-gentic.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/CodeByPeete/pi-gentic#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/CodeByPeete/pi-gentic/issues"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"pi-package",
|
|
16
|
+
"pi",
|
|
17
|
+
"pi-extension",
|
|
18
|
+
"agents",
|
|
19
|
+
"orchestration",
|
|
20
|
+
"session-management",
|
|
21
|
+
"worktrees"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"docs/assets",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"exports": "./dist/extension.js",
|
|
29
|
+
"types": "./dist/extension.d.ts",
|
|
30
|
+
"pi": {
|
|
31
|
+
"extensions": [
|
|
32
|
+
"./dist/extension.js"
|
|
33
|
+
],
|
|
34
|
+
"image": "https://raw.githubusercontent.com/CodeByPeete/pi-gentic/main/docs/assets/orchestration-tree.png"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
40
|
+
"test:ui": "npm run build && node test-ui/capture-ui.mjs",
|
|
41
|
+
"test:e2e": "npm run build && python test-e2e/capture-terminal-ui.py",
|
|
42
|
+
"prepack": "npm run build",
|
|
43
|
+
"pack:dry": "npm pack --dry-run"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "25.9.3",
|
|
47
|
+
"typescript": "6.0.3"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@earendil-works/pi-ai": "*",
|
|
51
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
52
|
+
"@earendil-works/pi-tui": "*"
|
|
53
|
+
},
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
}
|
|
58
|
+
}
|