pinokiod 7.2.17 → 7.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.
Files changed (78) hide show
  1. package/Dockerfile +2 -0
  2. package/kernel/api/index.js +1 -42
  3. package/kernel/api/process/index.js +44 -99
  4. package/kernel/bin/conda-python.js +30 -0
  5. package/kernel/bin/conda.js +22 -3
  6. package/kernel/bin/index.js +11 -1
  7. package/kernel/environment.js +2 -182
  8. package/kernel/git.js +13 -0
  9. package/kernel/index.js +1 -64
  10. package/kernel/plugin.js +58 -6
  11. package/kernel/shell.js +2 -21
  12. package/kernel/util.js +0 -60
  13. package/package.json +1 -1
  14. package/server/index.js +149 -176
  15. package/server/lib/content_validation.js +25 -28
  16. package/server/public/common.js +29 -103
  17. package/server/public/create-launcher.js +31 -4
  18. package/server/public/electron.css +6 -0
  19. package/server/public/style.css +0 -337
  20. package/server/public/task-launcher.js +32 -5
  21. package/server/public/universal-launcher.js +26 -3
  22. package/server/socket.js +11 -22
  23. package/server/views/app.ejs +30 -167
  24. package/server/views/d.ejs +33 -0
  25. package/server/views/editor.ejs +4 -25
  26. package/server/views/partials/main_sidebar.ejs +0 -1
  27. package/server/views/shell.ejs +3 -11
  28. package/server/views/terminal.ejs +3 -23
  29. package/server/views/terminals.ejs +0 -1
  30. package/spec/INSTRUCTION_SYNC.md +5 -5
  31. package/kernel/api/shell_run_template.js +0 -273
  32. package/kernel/api/uri/index.js +0 -51
  33. package/kernel/plugin_sources.js +0 -236
  34. package/kernel/watch/context.js +0 -42
  35. package/kernel/watch/drivers/fs.js +0 -71
  36. package/kernel/watch/drivers/poll.js +0 -33
  37. package/kernel/watch/index.js +0 -158
  38. package/server/features/drafts/index.js +0 -41
  39. package/server/features/drafts/parser.js +0 -169
  40. package/server/features/drafts/public/drafts.js +0 -1504
  41. package/server/features/drafts/registry_import.js +0 -412
  42. package/server/features/drafts/routes.js +0 -68
  43. package/server/features/drafts/service.js +0 -261
  44. package/server/features/drafts/watcher.js +0 -76
  45. package/server/features/index.js +0 -13
  46. package/server/lib/workspace_catalog.js +0 -151
  47. package/server/lib/workspace_runtime.js +0 -390
  48. package/server/routes/workspaces.js +0 -44
  49. package/server/views/partials/workspace_row.ejs +0 -61
  50. package/server/views/workspaces.ejs +0 -812
  51. package/system/plugin/antigravity/antigravity.png +0 -0
  52. package/system/plugin/antigravity/pinokio.js +0 -37
  53. package/system/plugin/claude/claude.png +0 -0
  54. package/system/plugin/claude/pinokio.js +0 -63
  55. package/system/plugin/claude-auto/claude.png +0 -0
  56. package/system/plugin/claude-auto/pinokio.js +0 -74
  57. package/system/plugin/claude-desktop/icon.jpeg +0 -0
  58. package/system/plugin/claude-desktop/pinokio.js +0 -39
  59. package/system/plugin/codex/openai.webp +0 -0
  60. package/system/plugin/codex/pinokio.js +0 -58
  61. package/system/plugin/codex-auto/openai.webp +0 -0
  62. package/system/plugin/codex-auto/pinokio.js +0 -65
  63. package/system/plugin/codex-desktop/icon.png +0 -0
  64. package/system/plugin/codex-desktop/pinokio.js +0 -39
  65. package/system/plugin/crush/crush.png +0 -0
  66. package/system/plugin/crush/pinokio.js +0 -31
  67. package/system/plugin/cursor/cursor.jpeg +0 -0
  68. package/system/plugin/cursor/pinokio.js +0 -39
  69. package/system/plugin/gemini/gemini.jpeg +0 -0
  70. package/system/plugin/gemini/pinokio.js +0 -40
  71. package/system/plugin/gemini-auto/gemini.jpeg +0 -0
  72. package/system/plugin/gemini-auto/pinokio.js +0 -43
  73. package/system/plugin/qwen/pinokio.js +0 -50
  74. package/system/plugin/qwen/qwen.png +0 -0
  75. package/system/plugin/vscode/pinokio.js +0 -36
  76. package/system/plugin/vscode/vscode.png +0 -0
  77. package/system/plugin/windsurf/pinokio.js +0 -39
  78. package/system/plugin/windsurf/windsurf.png +0 -0
@@ -1,261 +0,0 @@
1
- const fs = require("fs")
2
- const path = require("path")
3
- const crypto = require("crypto")
4
- const {
5
- RESULT_RELATIVE_DIR,
6
- POST_FILENAME,
7
- DEFAULT_READY_FILENAME,
8
- buildExcerpt,
9
- describeMediaRefs,
10
- extractTitle,
11
- parseDraftMetadata
12
- } = require("./parser")
13
-
14
- const STATE_FILENAME = "drafts.json"
15
- const MAX_PREVIEW_BYTES = 256 * 1024
16
-
17
- function createHash(value) {
18
- return crypto.createHash("sha256").update(String(value)).digest("hex").slice(0, 24)
19
- }
20
-
21
- function dismissalKey(id, revision) {
22
- const normalizedId = typeof id === "string" ? id.trim() : ""
23
- const normalizedRevision = typeof revision === "string" ? revision.trim() : ""
24
- return normalizedRevision ? `${normalizedId}:${normalizedRevision}` : normalizedId
25
- }
26
-
27
- function clonePlainObject(value) {
28
- if (!value || typeof value !== "object" || Array.isArray(value)) {
29
- return null
30
- }
31
- try {
32
- return JSON.parse(JSON.stringify(value))
33
- } catch (_) {
34
- return null
35
- }
36
- }
37
-
38
- function normalizeRelativePath(value, fallback) {
39
- const raw = String(value || fallback || "").trim().replace(/\\/g, "/")
40
- if (raw.startsWith("/") || /^[a-zA-Z]:/.test(raw)) {
41
- return fallback
42
- }
43
- const normalized = path.posix.normalize(raw)
44
- if (!normalized || normalized === "." || normalized === ".." || normalized.startsWith("../") || normalized.includes("/../")) {
45
- return fallback
46
- }
47
- return normalized
48
- }
49
-
50
- function normalizeDraftConfig(config = {}) {
51
- const params = config && typeof config === "object" ? config : {}
52
- return {
53
- path: normalizeRelativePath(params.path, RESULT_RELATIVE_DIR),
54
- content: normalizeRelativePath(params.content || params.post, POST_FILENAME),
55
- ready: normalizeRelativePath(params.ready, DEFAULT_READY_FILENAME),
56
- description: typeof params.description === "string" ? params.description.trim() : "",
57
- publish: clonePlainObject(params.publish)
58
- }
59
- }
60
-
61
- function createDraftService({ kernel, taskWorkspaceLinks } = {}) {
62
- if (!kernel) {
63
- throw new Error("kernel is required")
64
- }
65
-
66
- const statePath = () => path.resolve(kernel.path("tasks"), STATE_FILENAME)
67
- const resultsByWorkspace = new Map()
68
- const dismissedIds = new Set()
69
- let started = false
70
- let stateLoaded = false
71
-
72
- async function ensureStateLoaded() {
73
- if (stateLoaded) return
74
- stateLoaded = true
75
- try {
76
- const raw = await fs.promises.readFile(statePath(), "utf8")
77
- const parsed = JSON.parse(raw)
78
- if (parsed && Array.isArray(parsed.dismissed)) {
79
- parsed.dismissed.forEach((id) => {
80
- if (typeof id === "string" && id.trim()) {
81
- dismissedIds.add(id.trim())
82
- }
83
- })
84
- }
85
- } catch (_) {
86
- }
87
- }
88
-
89
- async function saveState() {
90
- await fs.promises.mkdir(path.dirname(statePath()), { recursive: true })
91
- const payload = {
92
- version: 1,
93
- dismissed: Array.from(dismissedIds).slice(-500)
94
- }
95
- await fs.promises.writeFile(statePath(), JSON.stringify(payload, null, 2))
96
- }
97
-
98
- async function readMarkdownPreview(postPath) {
99
- const handle = await fs.promises.open(postPath, "r")
100
- try {
101
- const buffer = Buffer.alloc(MAX_PREVIEW_BYTES)
102
- const read = await handle.read(buffer, 0, MAX_PREVIEW_BYTES, 0)
103
- return buffer.slice(0, read.bytesRead).toString("utf8")
104
- } finally {
105
- await handle.close().catch(() => {})
106
- }
107
- }
108
-
109
- async function readDraftMetadata(metadataPath) {
110
- if (path.extname(metadataPath).toLowerCase() !== ".json") {
111
- return {}
112
- }
113
- const raw = await fs.promises.readFile(metadataPath, "utf8")
114
- return parseDraftMetadata(raw)
115
- }
116
-
117
- async function inspectWorkspace({ taskId, ref, cwd, draft } = {}) {
118
- await ensureStateLoaded()
119
- if (typeof cwd !== "string" || !cwd.trim()) {
120
- return null
121
- }
122
- const workspacePath = path.resolve(cwd.trim())
123
- const draftConfig = normalizeDraftConfig(draft)
124
- const resultDir = path.resolve(workspacePath, draftConfig.path)
125
- const readyPath = path.resolve(resultDir, draftConfig.ready)
126
- const postPath = path.resolve(resultDir, draftConfig.content)
127
- const readyStats = await fs.promises.stat(readyPath).catch(() => null)
128
- const postStats = await fs.promises.stat(postPath).catch(() => null)
129
- if (!readyStats || !readyStats.isFile() || !postStats || !postStats.isFile()) {
130
- resultsByWorkspace.delete(workspacePath)
131
- return null
132
- }
133
- let metadata = {}
134
- try {
135
- metadata = await readDraftMetadata(readyPath)
136
- } catch (_) {
137
- resultsByWorkspace.delete(workspacePath)
138
- return null
139
- }
140
-
141
- const markdown = await readMarkdownPreview(postPath)
142
- const workspaceName = path.basename(workspacePath)
143
- const media = await describeMediaRefs(markdown, resultDir)
144
- const updatedAtMs = Math.max(readyStats.mtimeMs || 0, postStats.mtimeMs || 0)
145
- const id = createHash(`${workspacePath}|${resultDir}|${postPath}|${readyPath}`)
146
- const mediaRevision = media
147
- .map((item) => `${item.ref}:${item.exists ? item.bytes : "missing"}:${item.mtimeMs || 0}`)
148
- .join("|")
149
- const revision = createHash(`${postStats.size}|${postStats.mtimeMs}|${readyStats.size}|${readyStats.mtimeMs}|${mediaRevision}`)
150
- const result = {
151
- id,
152
- revision,
153
- taskId,
154
- ref,
155
- cwd: workspacePath,
156
- workspaceName,
157
- title: metadata.title || extractTitle(markdown, workspaceName),
158
- markdown,
159
- excerpt: buildExcerpt(markdown),
160
- resultDir,
161
- postPath,
162
- contentPath: postPath,
163
- readyPath,
164
- metadataPath: readyPath,
165
- metadata,
166
- publish: draftConfig.publish,
167
- description: draftConfig.description,
168
- postBytes: postStats.size,
169
- media: media.map((item, index) => ({
170
- index,
171
- ref: item.ref,
172
- path: item.path,
173
- bytes: item.bytes,
174
- mtimeMs: item.mtimeMs,
175
- exists: item.exists,
176
- ext: path.extname(item.ref || "").toLowerCase()
177
- })),
178
- mediaCount: media.length,
179
- missingMediaCount: media.filter((item) => !item.exists).length,
180
- mediaBytes: media.reduce((total, item) => total + (Number.isFinite(item.bytes) ? item.bytes : 0), 0),
181
- updatedAt: new Date(updatedAtMs || Date.now()).toISOString()
182
- }
183
- resultsByWorkspace.set(workspacePath, result)
184
- return result
185
- }
186
-
187
- async function trackWorkspace({ taskId, ref, cwd } = {}) {
188
- let resolvedCwd = cwd
189
- if (!resolvedCwd && ref && taskWorkspaceLinks && typeof taskWorkspaceLinks.resolveWorkspaceRef === "function") {
190
- resolvedCwd = taskWorkspaceLinks.resolveWorkspaceRef(ref)
191
- }
192
- if (!resolvedCwd) {
193
- return null
194
- }
195
- return inspectWorkspace({ taskId, ref, cwd: resolvedCwd })
196
- }
197
-
198
- async function listPending(options = {}) {
199
- await ensureStateLoaded()
200
- const filterCwd = typeof options.cwd === "string" && options.cwd.trim()
201
- ? path.resolve(options.cwd.trim())
202
- : ""
203
- return Array.from(resultsByWorkspace.values())
204
- .filter((result) => !dismissedIds.has(dismissalKey(result.id, result.revision)) && !dismissedIds.has(result.id))
205
- .filter((result) => !filterCwd || result.cwd === filterCwd)
206
- .sort((a, b) => String(b.updatedAt).localeCompare(String(a.updatedAt)))
207
- }
208
-
209
- async function getPendingById(id) {
210
- await ensureStateLoaded()
211
- const normalizedId = typeof id === "string" ? id.trim() : ""
212
- if (!normalizedId) {
213
- return null
214
- }
215
- const result = Array.from(resultsByWorkspace.values()).find((item) => item.id === normalizedId) || null
216
- if (!result || dismissedIds.has(dismissalKey(result.id, result.revision)) || dismissedIds.has(result.id)) {
217
- return null
218
- }
219
- return result
220
- }
221
-
222
- async function dismiss(id, revision) {
223
- await ensureStateLoaded()
224
- const normalizedId = typeof id === "string" ? id.trim() : ""
225
- if (!normalizedId) {
226
- return false
227
- }
228
- dismissedIds.add(dismissalKey(normalizedId, revision))
229
- await saveState()
230
- return true
231
- }
232
-
233
- async function refreshLinkedWorkspaces() {
234
- await ensureStateLoaded()
235
- }
236
-
237
- async function start() {
238
- if (started) return
239
- started = true
240
- await ensureStateLoaded()
241
- }
242
-
243
- async function stop() {
244
- }
245
-
246
- return {
247
- RESULT_RELATIVE_DIR,
248
- dismiss,
249
- getPendingById,
250
- inspectWorkspace,
251
- listPending,
252
- refreshLinkedWorkspaces,
253
- start,
254
- stop,
255
- trackWorkspace
256
- }
257
- }
258
-
259
- module.exports = {
260
- createDraftService
261
- }
@@ -1,76 +0,0 @@
1
- const path = require("path")
2
-
3
- function isInside(candidate, parent) {
4
- const relative = path.relative(parent, candidate)
5
- return relative === "" || (!!relative && !relative.startsWith("..") && !path.isAbsolute(relative))
6
- }
7
-
8
- class DraftWatcher {
9
- constructor(options = {}) {
10
- this.drafts = options.drafts
11
- }
12
-
13
- async ready(ctx, params = {}) {
14
- if (!this.drafts || typeof this.drafts.inspectWorkspace !== "function") {
15
- throw new Error("draft service is unavailable")
16
- }
17
-
18
- const draftDir = ctx.resolve(params.path || ".pinokio/draft")
19
- const draftConfig = {
20
- path: params.path || ".pinokio/draft",
21
- content: params.content,
22
- ready: params.ready,
23
- description: params.description,
24
- publish: params.publish
25
- }
26
- let timer = null
27
- let disposed = false
28
-
29
- const inspect = async () => {
30
- if (disposed) return
31
- await this.drafts.inspectWorkspace({ cwd: ctx.cwd, draft: draftConfig })
32
- }
33
-
34
- const scheduleInspect = () => {
35
- if (disposed) return
36
- if (timer) clearTimeout(timer)
37
- timer = setTimeout(() => {
38
- timer = null
39
- inspect().catch((error) => {
40
- console.warn("[drafts] failed to inspect workspace", error && error.message ? error.message : error)
41
- })
42
- }, 250)
43
- }
44
-
45
- await inspect()
46
- const stopPoll = ctx.poll(params.interval || 1500, inspect, {
47
- immediate: false,
48
- onError: (error) => {
49
- console.warn("[drafts] poll failed", error && error.message ? error.message : error)
50
- }
51
- })
52
- const unsubscribe = await ctx.watch.fs(ctx.cwd, (events) => {
53
- if (!Array.isArray(events)) return
54
- if (events.some((event) => event && event.path && isInside(path.resolve(event.path), draftDir))) {
55
- scheduleInspect()
56
- }
57
- })
58
-
59
- return async () => {
60
- if (timer) {
61
- clearTimeout(timer)
62
- timer = null
63
- }
64
- await this.drafts.inspectWorkspace({ cwd: ctx.cwd, draft: draftConfig }).catch(() => {})
65
- disposed = true
66
- if (typeof stopPoll === "function") {
67
- await stopPoll()
68
- }
69
- if (typeof unsubscribe === "function") {
70
- await unsubscribe()
71
- }
72
- }
73
- }
74
- }
75
-
76
- module.exports = DraftWatcher
@@ -1,13 +0,0 @@
1
- const { createDraftFeature } = require("./drafts")
2
-
3
- async function mountFeatures(options = {}) {
4
- const drafts = createDraftFeature(options)
5
- await drafts.start()
6
- return {
7
- drafts
8
- }
9
- }
10
-
11
- module.exports = {
12
- mountFeatures
13
- }
@@ -1,151 +0,0 @@
1
- const fs = require("fs")
2
- const path = require("path")
3
-
4
- const SORT_MODES = new Set(["most_used", "last_opened", "az"])
5
-
6
- function normalizeSortMode(sort) {
7
- if (SORT_MODES.has(sort)) return sort
8
- return "most_used"
9
- }
10
-
11
- function normalizePathKey(filepath) {
12
- const resolved = path.resolve(filepath).replace(/[\\/]+$/, "")
13
- return process.platform === "win32" ? resolved.toLowerCase() : resolved
14
- }
15
-
16
- function toRoutePath(filepath) {
17
- const resolved = path.resolve(filepath).replace(/\\/g, "/")
18
- const encoded = resolved
19
- .split("/")
20
- .map((segment, index) => {
21
- if (index === 0 && segment === "") return ""
22
- return encodeURIComponent(segment)
23
- })
24
- .join("/")
25
- return encoded.startsWith("/") ? `/d${encoded}` : `/d/${encoded}`
26
- }
27
-
28
- function latestTimestamp(values) {
29
- return values.reduce((latest, value) => {
30
- if (!value) return latest
31
- const timestamp = typeof value === "number" ? value : new Date(value).getTime()
32
- return Number.isFinite(timestamp) && timestamp > latest ? timestamp : latest
33
- }, 0)
34
- }
35
-
36
- function sortWorkspaces(items, sort) {
37
- const mode = normalizeSortMode(sort)
38
- const sorted = [...items]
39
- sorted.sort((a, b) => {
40
- if (mode === "az") {
41
- return a.name.localeCompare(b.name, undefined, { sensitivity: "base" })
42
- }
43
- if (mode === "last_opened") {
44
- const delta = (b.lastOpenedAtMs || b.modifiedAtMs || 0) - (a.lastOpenedAtMs || a.modifiedAtMs || 0)
45
- if (delta !== 0) return delta
46
- return a.name.localeCompare(b.name, undefined, { sensitivity: "base" })
47
- }
48
- const usageDelta = (b.usageCount || 0) - (a.usageCount || 0)
49
- if (usageDelta !== 0) return usageDelta
50
- return a.name.localeCompare(b.name, undefined, { sensitivity: "base" })
51
- })
52
- return sorted
53
- }
54
-
55
- function newestDraft(drafts) {
56
- return [...drafts].sort((a, b) => {
57
- return (new Date(b.updatedAt || 0).getTime() || 0) - (new Date(a.updatedAt || 0).getTime() || 0)
58
- })[0] || null
59
- }
60
-
61
- function createWorkspaceCatalogService({ kernel, workspaceRuntime, drafts }) {
62
- async function list(options = {}) {
63
- const sort = normalizeSortMode(options.sort)
64
- const root = path.resolve(kernel.path("workspaces"))
65
- const entries = await fs.promises.readdir(root, { withFileTypes: true }).catch(() => [])
66
- const runtime = workspaceRuntime.list()
67
- const liveByPath = new Map()
68
-
69
- for (const group of runtime.workspaces || []) {
70
- if (group.root !== "workspaces") continue
71
- liveByPath.set(normalizePathKey(group.cwd), group)
72
- }
73
-
74
- const draftByPath = new Map()
75
- const pendingDrafts = drafts ? await drafts.listPending({}).catch(() => []) : []
76
- for (const draft of pendingDrafts) {
77
- if (!draft.cwd) continue
78
- const key = normalizePathKey(draft.cwd)
79
- const list = draftByPath.get(key) || []
80
- list.push(draft)
81
- draftByPath.set(key, list)
82
- }
83
-
84
- const folders = entries.filter((entry) => entry.isDirectory())
85
- const items = []
86
-
87
- for (const entry of folders) {
88
- const cwd = path.join(root, entry.name)
89
- const stats = await fs.promises.stat(cwd).catch(() => null)
90
- const key = normalizePathKey(cwd)
91
- const live = liveByPath.get(key)
92
- const shells = live?.shells || []
93
- const scripts = live?.scripts || []
94
- const workspaceDrafts = draftByPath.get(key) || []
95
- const draft = newestDraft(workspaceDrafts)
96
- const modifiedAtMs = stats?.mtimeMs || 0
97
- const lastOpenedAtMs = latestTimestamp([
98
- modifiedAtMs,
99
- ...shells.map((shell) => shell.start_time),
100
- ...workspaceDrafts.map((item) => item.updatedAt),
101
- ])
102
- const primaryShell = shells.length === 1 ? shells[0] : null
103
- const primaryScript = scripts.length === 1 ? scripts[0] : null
104
- const usageCount = shells.length + scripts.length
105
-
106
- items.push({
107
- name: entry.name,
108
- cwd,
109
- relpath: entry.name,
110
- modifiedAt: modifiedAtMs ? new Date(modifiedAtMs).toISOString() : null,
111
- modifiedAtMs,
112
- lastOpenedAt: lastOpenedAtMs ? new Date(lastOpenedAtMs).toISOString() : null,
113
- lastOpenedAtMs,
114
- usageCount,
115
- running: shells.length > 0 || scripts.length > 0,
116
- counts: {
117
- shells: shells.length,
118
- scripts: scripts.length,
119
- drafts: workspaceDrafts.length,
120
- },
121
- shells,
122
- scripts,
123
- draft,
124
- draftReady: Boolean(draft),
125
- primaryUrl: primaryScript?.url || primaryShell?.url || null,
126
- launchUrl: toRoutePath(cwd),
127
- })
128
- }
129
-
130
- const running = sortWorkspaces(items.filter((item) => item.running), sort)
131
- const offline = sortWorkspaces(items.filter((item) => !item.running), sort)
132
-
133
- return {
134
- root,
135
- sort,
136
- running,
137
- offline,
138
- items: [...running, ...offline],
139
- counts: {
140
- total: items.length,
141
- running: running.length,
142
- offline: offline.length,
143
- drafts: items.filter((item) => item.draftReady).length,
144
- },
145
- }
146
- }
147
-
148
- return { list, normalizeSortMode }
149
- }
150
-
151
- module.exports = { createWorkspaceCatalogService, normalizeSortMode }