pinokiod 3.107.0 → 3.108.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/kernel/bin/git.js +12 -0
- package/kernel/environment.js +76 -0
- package/kernel/scripts/git/fork +21 -0
- package/kernel/scripts/git/push +1 -1
- package/package.json +1 -1
- package/server/index.js +34 -21
- package/server/views/app.ejs +960 -74
- package/server/views/pro.ejs +1 -1
package/kernel/bin/git.js
CHANGED
|
@@ -49,6 +49,13 @@ class Git {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
await fs.promises.mkdir(this.kernel.path("scripts/git"), { recursive: true }).catch((e) => { })
|
|
52
|
+
|
|
53
|
+
let gitfork_path = path.resolve(this.kernel.homedir, "scripts/git/fork.json")
|
|
54
|
+
await fs.promises.copyFile(
|
|
55
|
+
path.resolve(__dirname, "..", "scripts/git/fork"),
|
|
56
|
+
gitfork_path
|
|
57
|
+
)
|
|
58
|
+
|
|
52
59
|
let gitpush_path = path.resolve(this.kernel.homedir, "scripts/git/push.json")
|
|
53
60
|
await fs.promises.copyFile(
|
|
54
61
|
path.resolve(__dirname, "..", "scripts/git/push"),
|
|
@@ -106,6 +113,11 @@ class Git {
|
|
|
106
113
|
if (!exists4) {
|
|
107
114
|
return false;
|
|
108
115
|
}
|
|
116
|
+
let gitfork_path = path.resolve(this.kernel.homedir, "scripts/git/fork.json")
|
|
117
|
+
let exists5 = await this.kernel.api.exists(gitfork_path)
|
|
118
|
+
if (!exists5) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
109
121
|
|
|
110
122
|
if (this.kernel.platform === "darwin") {
|
|
111
123
|
let gh_config_exists = await this.kernel.exists("config/gh")
|
package/kernel/environment.js
CHANGED
|
@@ -557,6 +557,82 @@ const init = async (options, kernel) => {
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
+
|
|
561
|
+
const agentTemplatePath = kernel.path("prototype/system/AGENTS.md")
|
|
562
|
+
const agentTemplateExists = await kernel.exists(agentTemplatePath)
|
|
563
|
+
if (agentTemplateExists) {
|
|
564
|
+
const agentFiles = [
|
|
565
|
+
"AGENTS.md",
|
|
566
|
+
"CLAUDE.md",
|
|
567
|
+
"GEMINI.md",
|
|
568
|
+
"QWEN.md",
|
|
569
|
+
".windsurfrules",
|
|
570
|
+
".cursorrules",
|
|
571
|
+
".clinerules"
|
|
572
|
+
]
|
|
573
|
+
const structure_path = kernel.path("prototype/system/structure/clone")
|
|
574
|
+
const structure_content = await fs.promises.readFile(structure_path, "utf-8")
|
|
575
|
+
const rendered_recipe = await kernel.renderFile(agentTemplatePath, {
|
|
576
|
+
structure: structure_content,
|
|
577
|
+
examples: kernel.path("prototype/system/examples"),
|
|
578
|
+
browser_logs: kernel.path("logs/browser.log"),
|
|
579
|
+
PINOKIO_DOCUMENTATION: kernel.path("prototype/PINOKIO.md"),
|
|
580
|
+
PTERM_DOCUMENTATION: kernel.path("prototype/PTERM.md"),
|
|
581
|
+
app_root: root
|
|
582
|
+
})
|
|
583
|
+
for (const filename of agentFiles) {
|
|
584
|
+
const destination = path.resolve(root, filename)
|
|
585
|
+
const destinationExists = await kernel.exists(destination)
|
|
586
|
+
if (!destinationExists) {
|
|
587
|
+
await fs.promises.writeFile(destination, rendered_recipe)
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const gitDir = path.resolve(root, ".git")
|
|
593
|
+
const gitDirExists = await kernel.exists(gitDir)
|
|
594
|
+
if (gitDirExists) {
|
|
595
|
+
const excludePath = path.resolve(gitDir, "info/exclude")
|
|
596
|
+
await fs.promises.mkdir(path.dirname(excludePath), { recursive: true })
|
|
597
|
+
|
|
598
|
+
let excludeContent = ""
|
|
599
|
+
try {
|
|
600
|
+
excludeContent = await fs.promises.readFile(excludePath, "utf8")
|
|
601
|
+
} catch (error) {
|
|
602
|
+
if (error.code !== "ENOENT") {
|
|
603
|
+
throw error
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const existingEntries = new Set(
|
|
608
|
+
excludeContent
|
|
609
|
+
.split(/\r?\n/)
|
|
610
|
+
.map(line => line.trim())
|
|
611
|
+
.filter(line => line.length > 0)
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
const entriesToEnsure = [
|
|
615
|
+
"ENVIRONMENT",
|
|
616
|
+
".*",
|
|
617
|
+
"~*",
|
|
618
|
+
"/logs/",
|
|
619
|
+
"/cache/",
|
|
620
|
+
"/AGENTS.md",
|
|
621
|
+
"/CLAUDE.md",
|
|
622
|
+
"/GEMINI.md",
|
|
623
|
+
"/QWEN.md"
|
|
624
|
+
]
|
|
625
|
+
|
|
626
|
+
const missingEntries = entriesToEnsure.filter(entry => !existingEntries.has(entry))
|
|
627
|
+
if (missingEntries.length > 0) {
|
|
628
|
+
let appendContent = ""
|
|
629
|
+
if (excludeContent.length > 0 && !excludeContent.endsWith("\n")) {
|
|
630
|
+
appendContent += "\n"
|
|
631
|
+
}
|
|
632
|
+
appendContent += missingEntries.join("\n") + "\n"
|
|
633
|
+
await fs.promises.appendFile(excludePath, appendContent)
|
|
634
|
+
}
|
|
635
|
+
}
|
|
560
636
|
return {
|
|
561
637
|
relpath,
|
|
562
638
|
root_path: root,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"run": [{
|
|
3
|
+
"when": "{{args.org}}",
|
|
4
|
+
"method": "shell.run",
|
|
5
|
+
"params": {
|
|
6
|
+
"path": "{{args.cwd}}",
|
|
7
|
+
"message": [
|
|
8
|
+
"gh repo fork --remote=true --clone=false --fork-name {{args.name}} --org {{args.org}}"
|
|
9
|
+
]
|
|
10
|
+
}
|
|
11
|
+
}, {
|
|
12
|
+
"when": "{{!args.org}}",
|
|
13
|
+
"method": "shell.run",
|
|
14
|
+
"params": {
|
|
15
|
+
"path": "{{args.cwd}}",
|
|
16
|
+
"message": [
|
|
17
|
+
"gh repo fork --remote=true --clone=false --fork-name {{args.name}}"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}]
|
|
21
|
+
}
|
package/kernel/scripts/git/push
CHANGED
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -696,25 +696,28 @@ class Server {
|
|
|
696
696
|
|
|
697
697
|
await Environment.init({ name }, this.kernel)
|
|
698
698
|
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
let
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
699
|
+
/*
|
|
700
|
+
REPLACED OUT WITH using .git/info/exclude instead in order to not mess with 3rd party project .gitignore files but still exclude
|
|
701
|
+
*/
|
|
702
|
+
// // copy gitignore from ~pinokio/prototype/system/gitignore if it doesn't exist
|
|
703
|
+
//
|
|
704
|
+
//
|
|
705
|
+
// let gitignore_path = this.kernel.path("api/" + name + "/.gitignore")
|
|
706
|
+
// let dot_path = this.kernel.path("api", name, "pinokio")
|
|
707
|
+
// let gitignore_template_path = this.kernel.path("prototype/system/gitignore")
|
|
708
|
+
// let template_exists = await this.exists(gitignore_template_path)
|
|
709
|
+
// if (template_exists) {
|
|
710
|
+
// let exists = await this.exists(dot_path)
|
|
711
|
+
// if (exists) {
|
|
712
|
+
// // 1. when importing existing projects (.pinokio exists), don't mess with .gitignore
|
|
713
|
+
// } else {
|
|
714
|
+
// // 2. otherwise, merge gitignore
|
|
715
|
+
// await Util.mergeLines(
|
|
716
|
+
// gitignore_path, // existing path
|
|
717
|
+
// gitignore_template_path // overwrite with template
|
|
718
|
+
// )
|
|
719
|
+
// }
|
|
720
|
+
// }
|
|
718
721
|
|
|
719
722
|
|
|
720
723
|
|
|
@@ -848,7 +851,8 @@ class Server {
|
|
|
848
851
|
git_history_url: `/info/git/HEAD/${name}`,
|
|
849
852
|
git_status_url: `/info/gitstatus/${name}`,
|
|
850
853
|
git_push_url: `/run/scripts/git/push.json?cwd=${encodeURIComponent(this.kernel.path('api', name))}`,
|
|
851
|
-
git_create_url: `/run/scripts/git/create.json?cwd=${encodeURIComponent(this.kernel.path('api', name))}
|
|
854
|
+
git_create_url: `/run/scripts/git/create.json?cwd=${encodeURIComponent(this.kernel.path('api', name))}`,
|
|
855
|
+
git_fork_url: `/run/scripts/git/fork.json?cwd=${encodeURIComponent(this.kernel.path('api', name))}`
|
|
852
856
|
// rawpath,
|
|
853
857
|
}
|
|
854
858
|
// if (!this.kernel.proto.config) {
|
|
@@ -1202,10 +1206,15 @@ class Server {
|
|
|
1202
1206
|
|
|
1203
1207
|
const repoHistoryUrl = repoParam ? `/info/git/HEAD/${repoParam}` : null
|
|
1204
1208
|
|
|
1209
|
+
const forkUrl = `/run/scripts/git/fork.json?cwd=${encodeURIComponent(dir)}`
|
|
1210
|
+
const pushUrl = `/run/scripts/git/push.json?cwd=${encodeURIComponent(dir)}`
|
|
1211
|
+
|
|
1205
1212
|
return {
|
|
1206
1213
|
changes,
|
|
1207
1214
|
git_commit_url: `/run/scripts/git/commit.json?cwd=${dir}&callback_target=parent&callback=$location.href`,
|
|
1208
1215
|
git_history_url: repoHistoryUrl,
|
|
1216
|
+
git_fork_url: forkUrl,
|
|
1217
|
+
git_push_url: pushUrl,
|
|
1209
1218
|
}
|
|
1210
1219
|
}
|
|
1211
1220
|
async computeWorkspaceGitStatus(workspaceName) {
|
|
@@ -1218,7 +1227,7 @@ class Server {
|
|
|
1218
1227
|
for (const repo of repos) {
|
|
1219
1228
|
const repoParam = repo.gitParentRelPath || workspaceName
|
|
1220
1229
|
try {
|
|
1221
|
-
const { changes, git_commit_url, git_history_url } = await this.getRepoHeadStatus(repoParam)
|
|
1230
|
+
const { changes, git_commit_url, git_history_url, git_fork_url, git_push_url } = await this.getRepoHeadStatus(repoParam)
|
|
1222
1231
|
const historyUrl = git_history_url || (repoParam ? `/info/git/HEAD/${repoParam}` : `/info/git/HEAD/${workspaceName}`)
|
|
1223
1232
|
statuses.push({
|
|
1224
1233
|
name: repo.name,
|
|
@@ -1229,6 +1238,8 @@ class Server {
|
|
|
1229
1238
|
changes,
|
|
1230
1239
|
git_commit_url,
|
|
1231
1240
|
git_history_url: historyUrl,
|
|
1241
|
+
git_fork_url,
|
|
1242
|
+
git_push_url,
|
|
1232
1243
|
url: repo.url || null,
|
|
1233
1244
|
})
|
|
1234
1245
|
} catch (error) {
|
|
@@ -1243,6 +1254,8 @@ class Server {
|
|
|
1243
1254
|
changes: [],
|
|
1244
1255
|
git_commit_url: null,
|
|
1245
1256
|
git_history_url: historyUrl,
|
|
1257
|
+
git_fork_url: `/run/scripts/git/fork.json?cwd=${encodeURIComponent(this.kernel.path('api', repoParam))}`,
|
|
1258
|
+
git_push_url: `/run/scripts/git/push.json?cwd=${encodeURIComponent(this.kernel.path('api', repoParam))}`,
|
|
1246
1259
|
url: repo.url || null,
|
|
1247
1260
|
error: error ? String(error.message || error) : 'unknown',
|
|
1248
1261
|
})
|