@kriya-ai/harness 0.0.0-stage → 0.2.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 +379 -2
- package/SAFETY.md +162 -0
- package/THIRD_PARTY_NOTICES.md +7911 -0
- package/bin/kriya.js +577 -0
- package/bundle/cordis.patch.yml +397 -0
- package/contract/SOURCE.md +15 -0
- package/contract/contract.json +1355 -0
- package/package.json +57 -4
- package/plugins/anchor/index.js +56 -0
- package/plugins/anchor/package.json +13 -0
- package/plugins/approvals/index.js +183 -0
- package/plugins/approvals/package.json +13 -0
- package/plugins/brand/DESIGN.md +112 -0
- package/plugins/brand/client.js +826 -0
- package/plugins/brand/index.js +15 -0
- package/plugins/brand/package.json +25 -0
- package/plugins/brand/src/client.js +823 -0
- package/plugins/browser/index.js +218 -0
- package/plugins/browser/package.json +13 -0
- package/plugins/budget/index.js +108 -0
- package/plugins/budget/package.json +13 -0
- package/plugins/changes/client.js +245 -0
- package/plugins/changes/index.js +75 -0
- package/plugins/changes/package.json +22 -0
- package/plugins/edit/client.js +113 -0
- package/plugins/edit/index.js +58 -0
- package/plugins/edit/package.json +23 -0
- package/plugins/fs-freshness/index.js +28 -0
- package/plugins/fs-freshness/package.json +13 -0
- package/plugins/graph/client.js +178 -0
- package/plugins/graph/index.js +4 -0
- package/plugins/graph/package.json +22 -0
- package/plugins/kriya-handoff/index.js +194 -0
- package/plugins/kriya-handoff/package.json +13 -0
- package/plugins/kriya-tools/index.js +189 -0
- package/plugins/kriya-tools/package.json +13 -0
- package/plugins/loop/index.js +743 -0
- package/plugins/loop/package.json +13 -0
- package/plugins/mirror/index.js +235 -0
- package/plugins/mirror/package.json +13 -0
- package/plugins/overview/client.js +276 -0
- package/plugins/overview/index.js +95 -0
- package/plugins/overview/package.json +22 -0
- package/plugins/preview/client.js +337 -0
- package/plugins/preview/index.js +4 -0
- package/plugins/preview/package.json +22 -0
- package/plugins/progress/client.js +290 -0
- package/plugins/progress/index.js +100 -0
- package/plugins/progress/package.json +22 -0
- package/plugins/projects/client.js +249 -0
- package/plugins/projects/index.js +30 -0
- package/plugins/projects/package.json +24 -0
- package/plugins/rea/index.js +256 -0
- package/plugins/rea/package.json +10 -0
- package/plugins/rea/skill/LICENSE +21 -0
- package/plugins/rea/skill/SKILL.md +360 -0
- package/plugins/rea/skill/references/android-applications.md +36 -0
- package/plugins/rea/skill/references/connection-and-recovery.md +127 -0
- package/plugins/rea/skill/references/evidence-workflows.md +71 -0
- package/plugins/rea/skill/references/javascript-applications.md +218 -0
- package/plugins/rea/skill/references/native-and-artifacts.md +297 -0
- package/plugins/rea/skill/references/runtime-observation.md +78 -0
- package/plugins/remote/index.js +297 -0
- package/plugins/remote/package.json +10 -0
- package/plugins/router/index.js +84 -0
- package/plugins/router/package.json +13 -0
- package/plugins/sessions/client.js +68 -0
- package/plugins/sessions/index.js +79 -0
- package/plugins/sessions/package.json +20 -0
- package/plugins/skills/client.js +504 -0
- package/plugins/skills/index.js +166 -0
- package/plugins/skills/package.json +23 -0
- package/src/api.js +97 -0
- package/src/browser.js +286 -0
- package/src/changes.js +191 -0
- package/src/checkpoints.js +313 -0
- package/src/daemon.js +503 -0
- package/src/doctor.js +137 -0
- package/src/edit/core/anchors.js +102 -0
- package/src/edit/core/audio.js +158 -0
- package/src/edit/core/faces.js +99 -0
- package/src/edit/core/ffmpeg.js +258 -0
- package/src/edit/core/handoff.js +220 -0
- package/src/edit/core/history.js +90 -0
- package/src/edit/core/layout.js +92 -0
- package/src/edit/core/mix.js +115 -0
- package/src/edit/core/ops.js +602 -0
- package/src/edit/core/plan.js +266 -0
- package/src/edit/core/project.d.ts +134 -0
- package/src/edit/core/project.js +307 -0
- package/src/edit/core/reframe.js +125 -0
- package/src/edit/core/solver.js +416 -0
- package/src/edit/core/time.js +110 -0
- package/src/edit/core/tonemap.js +57 -0
- package/src/edit/director/ask.js +120 -0
- package/src/edit/director/gateway.js +16 -0
- package/src/edit/director/revise.js +186 -0
- package/src/edit/engine/capabilities.js +33 -0
- package/src/edit/engine/captions.js +154 -0
- package/src/edit/engine/color.js +269 -0
- package/src/edit/engine/confine.js +67 -0
- package/src/edit/engine/dna.js +148 -0
- package/src/edit/engine/index.js +473 -0
- package/src/edit/engine/loudness.js +43 -0
- package/src/edit/engine/media.js +57 -0
- package/src/edit/engine/motion.js +281 -0
- package/src/edit/engine/packs.js +87 -0
- package/src/edit/engine/probe.js +101 -0
- package/src/edit/engine/receipt.js +123 -0
- package/src/edit/engine/tool.js +101 -0
- package/src/edit/gates/copy.js +113 -0
- package/src/edit/gates/index.js +430 -0
- package/src/edit/gates/picture.js +130 -0
- package/src/edit/gates/sound.js +58 -0
- package/src/edit/gates/speech.js +127 -0
- package/src/edit/gates/text.js +196 -0
- package/src/edit/gates/text.swift +22 -0
- package/src/edit/graph/index.js +139 -0
- package/src/edit/graph/journal.js +69 -0
- package/src/edit/graph/scheduler.js +79 -0
- package/src/edit/host/client.js +58 -0
- package/src/edit/host/deliver.js +119 -0
- package/src/edit/host/jobs.js +84 -0
- package/src/edit/host/main.js +135 -0
- package/src/edit/host/paths.js +11 -0
- package/src/edit/host/projects.js +415 -0
- package/src/edit/host/server.js +391 -0
- package/src/edit/host/taste.js +135 -0
- package/src/edit/host/tavi.js +417 -0
- package/src/edit/host/watch.js +141 -0
- package/src/edit/index/db.js +109 -0
- package/src/edit/index/index.js +236 -0
- package/src/edit/index/layers/faces.js +78 -0
- package/src/edit/index/layers/faces.swift +18 -0
- package/src/edit/index/layers/meta.js +35 -0
- package/src/edit/index/layers/music.js +146 -0
- package/src/edit/index/layers/quality.js +120 -0
- package/src/edit/index/layers/retakes.js +132 -0
- package/src/edit/index/layers/screen.js +99 -0
- package/src/edit/index/layers/shots.js +29 -0
- package/src/edit/index/layers/sound.js +42 -0
- package/src/edit/index/layers/words.js +64 -0
- package/src/edit/index/story.js +248 -0
- package/src/edit/index/views.js +71 -0
- package/src/edit/loop/governor.js +112 -0
- package/src/edit/loop/loop.js +69 -0
- package/src/edit/loop/make.js +115 -0
- package/src/edit/loop/repair.js +97 -0
- package/src/edit/loop/replay.js +32 -0
- package/src/edit/recipes/multicam.js +461 -0
- package/src/edit/recipes/reel.js +202 -0
- package/src/edit/recipes/short-from-long.js +237 -0
- package/src/edit/recipes/tutorial.js +137 -0
- package/src/edit/recipes/youtube.js +155 -0
- package/src/edit/runtime/cli.js +126 -0
- package/src/edit/runtime/doctor.js +122 -0
- package/src/edit/runtime/fetch.js +15 -0
- package/src/edit/runtime/licences.js +88 -0
- package/src/edit/runtime/manifest.js +73 -0
- package/src/edit/runtime/setup.js +252 -0
- package/src/failure.js +69 -0
- package/src/gateway-proxy.js +213 -0
- package/src/intent.js +130 -0
- package/src/launch.js +315 -0
- package/src/live.js +81 -0
- package/src/local-skills.js +284 -0
- package/src/login.js +82 -0
- package/src/loop.js +428 -0
- package/src/modes.js +128 -0
- package/src/overview.js +71 -0
- package/src/paths.js +30 -0
- package/src/profiles.js +92 -0
- package/src/projects.js +104 -0
- package/src/recon.js +244 -0
- package/src/rules.js +139 -0
- package/src/runner.bundle.js +21172 -0
- package/src/sentinel.js +248 -0
- package/src/skill-switches.js +130 -0
- package/src/store.js +58 -0
- package/src/strict.js +124 -0
- package/src/verify.js +659 -0
- package/src/world.js +268 -0
- package/studio/dist/index.html +14 -0
- package/studio/dist/studio.css +163 -0
- package/studio/dist/studio.js +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { planStatus } from "../../src/loop.js"
|
|
2
|
+
import { projectRoot } from "../../src/skill-switches.js"
|
|
3
|
+
import { confirmCheck, confirmedCheck, currentVerdict, discoverChecks, readProgress } from "../../src/verify.js"
|
|
4
|
+
import { ChangesError } from "../../src/changes.js"
|
|
5
|
+
|
|
6
|
+
// The Progress tab, node half: one read-only route inside Connection's
|
|
7
|
+
// fence (as plugins/changes). For one session, what the Kriya loop recorded
|
|
8
|
+
// (src/verify.js, src/loop.js): the goal and plan, each step's status and
|
|
9
|
+
// attempts, every check run with its exit code and failure class, and the
|
|
10
|
+
// verdict against the files as they are now. All of it comes from verified
|
|
11
|
+
// runs the harness made, never from what the model wrote.
|
|
12
|
+
|
|
13
|
+
export const name = "kriya-progress"
|
|
14
|
+
export const inject = ["connection", "sessions"]
|
|
15
|
+
|
|
16
|
+
export const ROUTE = "/api/kriya.progress"
|
|
17
|
+
// The person confirms one of the checks the harness found (as `kriya verify use <number>`)
|
|
18
|
+
export const CHECK_ROUTE = "/api/kriya.progress.check"
|
|
19
|
+
const SUGGESTIONS = 5
|
|
20
|
+
const RUNS = 30
|
|
21
|
+
|
|
22
|
+
/** @param {{ folderOf: (id: string) => Promise<string | undefined>, verdictOf?: typeof currentVerdict }} host */
|
|
23
|
+
export function handler({ folderOf, verdictOf = currentVerdict }) {
|
|
24
|
+
return async (request) => {
|
|
25
|
+
const id = new URL(request.url).searchParams.get("session")
|
|
26
|
+
if (!id || id.length > 200) throw new ChangesError("Which session?")
|
|
27
|
+
const cwd = await folderOf(id)
|
|
28
|
+
if (!cwd) throw new ChangesError("That session isn't known here.")
|
|
29
|
+
const check = confirmedCheck(cwd)
|
|
30
|
+
let progress
|
|
31
|
+
try {
|
|
32
|
+
progress = readProgress(projectRoot(cwd), id)
|
|
33
|
+
} catch {
|
|
34
|
+
// A session id that can't name a progress file has no progress
|
|
35
|
+
progress = { runs: [] }
|
|
36
|
+
}
|
|
37
|
+
const verdict = progress.runs.length ? await verdictOf(cwd, id) : { status: "not checked", steps: [] }
|
|
38
|
+
const plan = progress.plan
|
|
39
|
+
? { goal: progress.plan.goal, at: progress.plan.at, steps: planStatus(cwd, id).map((s, i) => ({ ...s, doneWhen: progress.plan.steps[i].doneWhen, files: progress.plan.steps[i].files })) }
|
|
40
|
+
: null
|
|
41
|
+
return {
|
|
42
|
+
check: check ? { command: check.command, source: check.source ?? "kriya verify use" } : null,
|
|
43
|
+
...(!check && { suggestions: discoverChecks(cwd).slice(0, SUGGESTIONS).map((s) => ({ command: s.command, source: s.source })) }),
|
|
44
|
+
plan,
|
|
45
|
+
earlierPlans: progress.earlier?.length ?? 0,
|
|
46
|
+
verdict: { status: verdict.status, ...(verdict.stale && { stale: true }), ...(verdict.touched && { touched: verdict.touched }) },
|
|
47
|
+
runs: progress.runs
|
|
48
|
+
.slice(-RUNS)
|
|
49
|
+
.reverse()
|
|
50
|
+
.map((r) => ({ at: r.at, step: r.step, status: r.status, exitCode: r.exitCode ?? null, timedOut: Boolean(r.timedOut), durationMs: r.durationMs, ...(r.kind && { kind: r.kind }), ...(r.weakened && { weakened: r.weakened }) })),
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The person's one click in the Progress tab: confirm one of the checks the
|
|
57
|
+
* harness discovered for the session's folder. Only a discovered command is
|
|
58
|
+
* accepted (a typed one stays `kriya verify use` in a terminal), and only
|
|
59
|
+
* from the Web UI, inside Connection's fence; no agent tool reaches it.
|
|
60
|
+
* @param {{ folderOf: (id: string) => Promise<string | undefined> }} host
|
|
61
|
+
*/
|
|
62
|
+
export function checkHandler({ folderOf }) {
|
|
63
|
+
return async (request) => {
|
|
64
|
+
if (!/^application\/json\b/i.test(request.headers.get("content-type") ?? "")) throw new ChangesError("Send JSON.")
|
|
65
|
+
const body = await request.json().catch(() => null)
|
|
66
|
+
const id = typeof body?.session === "string" ? body.session : ""
|
|
67
|
+
if (!id || id.length > 200) throw new ChangesError("Which session?")
|
|
68
|
+
const cwd = await folderOf(id)
|
|
69
|
+
if (!cwd) throw new ChangesError("That session isn't known here.")
|
|
70
|
+
const found = discoverChecks(cwd).slice(0, SUGGESTIONS).find((s) => s.command === body?.command)
|
|
71
|
+
if (!found) throw new ChangesError("That isn't one of the checks found for this project; use kriya verify use in a terminal.")
|
|
72
|
+
const { command } = confirmCheck(cwd, found.command)
|
|
73
|
+
return { check: { command, source: "kriya verify use" } }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const reply = (body, status = 200) => Response.json(body, { status, headers: { "cache-control": "no-store" } })
|
|
78
|
+
|
|
79
|
+
export async function answer(route, request, log = () => {}) {
|
|
80
|
+
try {
|
|
81
|
+
return reply(await route(request))
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof ChangesError) return reply({ error: error.message }, 400)
|
|
84
|
+
log(error)
|
|
85
|
+
return reply({ error: "Kriya couldn't read this session's progress; see the terminal for details." }, 500)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function apply(ctx) {
|
|
90
|
+
const folderOf = async (id) => {
|
|
91
|
+
const live = ctx.sessions.get(id)?.header
|
|
92
|
+
const stored = live === undefined ? await ctx.get("sessionPersistence")?.stat(id) : undefined
|
|
93
|
+
return (live ?? stored?.header)?.cwd
|
|
94
|
+
}
|
|
95
|
+
const route = handler({ folderOf })
|
|
96
|
+
const log = (error) => ctx.logger("kriya-progress").warn(error)
|
|
97
|
+
ctx.effect(() => ctx.connection.fetch.register({ path: ROUTE, methods: ["GET"], requestBody: "buffered", fetch: (request) => answer(route, request, log) }))
|
|
98
|
+
const confirm = checkHandler({ folderOf })
|
|
99
|
+
ctx.effect(() => ctx.connection.fetch.register({ path: CHECK_ROUTE, methods: ["POST"], requestBody: "buffered", fetch: (request) => answer(confirm, request, log) }))
|
|
100
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriya-ai/harness-progress",
|
|
3
|
+
"description": "The Progress tab of the Kriya Harness Web UI: what the Kriya loop recorded for a session, from verified check runs",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./client": "./client.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"dsh": {
|
|
14
|
+
"client": {
|
|
15
|
+
"inject": [
|
|
16
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right"
|
|
17
|
+
],
|
|
18
|
+
"platform": "web"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"license": "UNLICENSED"
|
|
22
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
// The Projects page, browser half: a "Projects" row in the sidebar's panel
|
|
2
|
+
// list and its page in the layout's main slot (the seats the Skills page
|
|
3
|
+
// uses). It lists the project folders the Host finds (index.js) and opens
|
|
4
|
+
// one the way DSH's own sidebar does: the folder becomes a workspace
|
|
5
|
+
// (ctx.workspaces.create), then a session opens in it
|
|
6
|
+
// (ctx.uiWorkspace.openWorkspace, what DSH's "New session in …" calls). No DSH file is edited (HD-02).
|
|
7
|
+
window.__ModuleLoader__.load({
|
|
8
|
+
id: "@kriya-ai/harness-projects",
|
|
9
|
+
factory: (require) => {
|
|
10
|
+
const React = require("react")
|
|
11
|
+
const { useCallback, useEffect, useMemo, useState, useSyncExternalStore } = React
|
|
12
|
+
const h = React.createElement
|
|
13
|
+
|
|
14
|
+
const PLUGIN = "@kriya-ai/harness-projects"
|
|
15
|
+
const PANEL_ID = "kriya-projects"
|
|
16
|
+
const API = "api/kriya.projects"
|
|
17
|
+
|
|
18
|
+
/* ─────────────────────────────── styles ─────────────────────────────── */
|
|
19
|
+
|
|
20
|
+
const CSS = `
|
|
21
|
+
.kh-pj { display: flex; flex-direction: column; height: 100%; min-height: 0; color: var(--dsw-alias-label-primary); font-size: 14px; }
|
|
22
|
+
.kh-pj-head { padding: 32px 32px 18px; display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; justify-content: space-between; }
|
|
23
|
+
.kh-pj-title { margin: 0 0 6px; font-family: var(--dsw-font-family-brand); font-size: 30px; line-height: 36px; font-weight: 420; font-variation-settings: "opsz" 72, "SOFT" 80; letter-spacing: -0.016em; }
|
|
24
|
+
.kh-pj-sub { margin: 0; max-width: 60ch; color: var(--dsw-alias-label-secondary); line-height: 1.5; }
|
|
25
|
+
.kh-pj-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
26
|
+
.kh-pj-search { width: min(320px, 100%); box-sizing: border-box; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 0; background: var(--kh-well, var(--dsw-alias-bg-layer-1)); box-shadow: inset 0 0 0 .5px var(--kh-edge, var(--dsw-alias-border-l3)); color: inherit; font: inherit; }
|
|
27
|
+
.kh-pj-btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--kh-chip, var(--dsw-alias-bg-layer-1)); box-shadow: var(--kh-rim, inset 0 0 0 1px var(--dsw-alias-border-l3)); color: inherit; font: inherit; font-weight: 500; cursor: pointer; transition: background-color .16s; }
|
|
28
|
+
.kh-pj-btn:hover:not(:disabled) { background: var(--kh-chip-hover, var(--dsw-alias-bg-layer-2)); }
|
|
29
|
+
.kh-pj-btn:disabled { opacity: .55; cursor: default; }
|
|
30
|
+
.kh-pj-btn.primary { background: var(--dsw-alias-button-info-fill); color: var(--dsw-alias-label-primary-foreground); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), 0 4px 12px -6px var(--kh-press-shadow, transparent); }
|
|
31
|
+
.kh-pj-btn.primary:hover:not(:disabled) { background: var(--dsw-alias-button-info-hover); }
|
|
32
|
+
.kh-pj-search:focus-visible, .kh-pj-btn:focus-visible { outline: 2px solid var(--dsw-alias-link); outline-offset: 2px; }
|
|
33
|
+
.kh-pj-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 32px 32px; }
|
|
34
|
+
.kh-pj-group { margin: 18px 4px 8px; font-size: 12.5px; font-weight: 500; color: var(--dsw-alias-label-tertiary); font-family: var(--dsw-font-family-code, ui-monospace, monospace); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
|
|
35
|
+
.kh-pj-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
|
|
36
|
+
.kh-pj-card { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 12px 12px 16px; border-radius: 16px; background: var(--kh-glass-thick, var(--dsw-alias-bg-layer-1)); box-shadow: var(--kh-rim, inset 0 0 0 1px var(--dsw-alias-border-l2)), 0 1px 2px var(--kh-shade, transparent); }
|
|
37
|
+
.kh-pj-main { flex: 1; min-width: 0; }
|
|
38
|
+
.kh-pj-name { font-weight: 560; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
39
|
+
.kh-pj-path { margin-top: 2px; font-family: var(--dsw-font-family-code, ui-monospace, monospace); font-size: 12px; color: var(--dsw-alias-label-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
|
|
40
|
+
.kh-pj-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
|
|
41
|
+
.kh-pj-tag { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--kh-well, var(--dsw-alias-bg-layer-2)); color: var(--dsw-alias-label-secondary); }
|
|
42
|
+
.kh-pj-tag.here { background: var(--dsw-alias-state-business-tertiary); color: var(--dsw-alias-link); }
|
|
43
|
+
.kh-pj-open { flex: none; min-width: 72px; }
|
|
44
|
+
.kh-pj-note { color: var(--dsw-alias-label-secondary); line-height: 1.55; max-width: 64ch; padding: 24px 4px; }
|
|
45
|
+
.kh-pj-note code { font-family: var(--dsw-font-family-code, ui-monospace, monospace); font-size: 12.5px; }
|
|
46
|
+
.kh-pj-error { color: var(--dsw-alias-state-error-primary); padding: 0 32px 8px; }
|
|
47
|
+
@media (max-width: 760px) {
|
|
48
|
+
.kh-pj-head { padding: 20px 16px 12px; }
|
|
49
|
+
.kh-pj-body { padding: 4px 16px 24px; }
|
|
50
|
+
.kh-pj-search { width: 100%; }
|
|
51
|
+
.kh-pj-tools { width: 100%; }
|
|
52
|
+
}
|
|
53
|
+
`
|
|
54
|
+
|
|
55
|
+
function installStyles() {
|
|
56
|
+
const tag = document.createElement("style")
|
|
57
|
+
tag.dataset.plugin = PLUGIN
|
|
58
|
+
tag.textContent = CSS
|
|
59
|
+
document.head.appendChild(tag)
|
|
60
|
+
return () => tag.remove()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ──────────────────────────────── icon ──────────────────────────────── */
|
|
64
|
+
|
|
65
|
+
// A folder with a spark of work in it
|
|
66
|
+
function ProjectsIcon({ size = 20 }) {
|
|
67
|
+
return h(
|
|
68
|
+
"svg",
|
|
69
|
+
{ width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true },
|
|
70
|
+
h("path", { d: "M3 7.5A2.5 2.5 0 0 1 5.5 5H9l2 2.5h7.5A2.5 2.5 0 0 1 21 10v7.5a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 17.5v-10Z" }),
|
|
71
|
+
h("path", { d: "M10 14.5h5M12.5 12v5" })
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ──────────────────────────────── page ──────────────────────────────── */
|
|
76
|
+
|
|
77
|
+
/** Resolves with the workspace for `path` once the client's list has it. */
|
|
78
|
+
function workspaceFor(workspaces, path, timeoutMs = 10000) {
|
|
79
|
+
const find = () => workspaces.list.getSnapshot().items.find((item) => item.path === path)
|
|
80
|
+
return new Promise((done, fail) => {
|
|
81
|
+
const now = find()
|
|
82
|
+
if (now) return done(now)
|
|
83
|
+
const timer = setTimeout(() => {
|
|
84
|
+
stop()
|
|
85
|
+
fail(new Error("The workspace didn't appear; try again."))
|
|
86
|
+
}, timeoutMs)
|
|
87
|
+
const stop = workspaces.list.subscribe(() => {
|
|
88
|
+
const next = find()
|
|
89
|
+
if (!next) return
|
|
90
|
+
clearTimeout(timer)
|
|
91
|
+
stop()
|
|
92
|
+
done(next)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const since = (iso) => {
|
|
98
|
+
const days = Math.floor((Date.now() - Date.parse(iso)) / 86400000)
|
|
99
|
+
if (days < 1) return "changed today"
|
|
100
|
+
if (days < 2) return "changed yesterday"
|
|
101
|
+
if (days < 31) return `changed ${days} days ago`
|
|
102
|
+
return `changed ${new Date(iso).toLocaleDateString(undefined, { month: "short", year: "numeric" })}`
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function makePage(ctx) {
|
|
106
|
+
const { workspaces, uiWorkspace } = ctx
|
|
107
|
+
const subscribe = (fn) => workspaces.list.subscribe(fn)
|
|
108
|
+
const snapshot = () => workspaces.list.getSnapshot()
|
|
109
|
+
|
|
110
|
+
return function ProjectsPage() {
|
|
111
|
+
const [state, setState] = useState({ loading: true, projects: [], roots: [], truncated: false, error: "" })
|
|
112
|
+
const [query, setQuery] = useState("")
|
|
113
|
+
const [opening, setOpening] = useState("")
|
|
114
|
+
const [error, setError] = useState("")
|
|
115
|
+
const open = useSyncExternalStore(subscribe, snapshot)
|
|
116
|
+
const openPaths = useMemo(() => new Set(open.items.map((item) => item.path)), [open])
|
|
117
|
+
|
|
118
|
+
const load = useCallback(async () => {
|
|
119
|
+
setState((s) => ({ ...s, loading: true, error: "" }))
|
|
120
|
+
try {
|
|
121
|
+
const response = await fetch(API, { credentials: "same-origin" })
|
|
122
|
+
const data = await response.json().catch(() => ({}))
|
|
123
|
+
if (!response.ok) throw new Error(data.error || `Kriya answered ${response.status}.`)
|
|
124
|
+
setState({ loading: false, projects: data.projects, roots: data.roots, truncated: data.truncated, error: "" })
|
|
125
|
+
} catch (e) {
|
|
126
|
+
setState((s) => ({ ...s, loading: false, error: e.message }))
|
|
127
|
+
}
|
|
128
|
+
}, [])
|
|
129
|
+
useEffect(() => void load(), [load])
|
|
130
|
+
|
|
131
|
+
const openProject = async (project) => {
|
|
132
|
+
setOpening(project.path)
|
|
133
|
+
setError("")
|
|
134
|
+
try {
|
|
135
|
+
if (!openPaths.has(project.path)) await workspaces.create({ path: project.path })
|
|
136
|
+
const workspace = await workspaceFor(workspaces, project.path)
|
|
137
|
+
// DSH's own "New session in …": a blank session there, revealed
|
|
138
|
+
await uiWorkspace.openWorkspace(workspace.workspaceId)
|
|
139
|
+
} catch (e) {
|
|
140
|
+
setError(`Couldn't open ${project.name}: ${e.message}`)
|
|
141
|
+
} finally {
|
|
142
|
+
setOpening("")
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const shown = useMemo(() => {
|
|
147
|
+
const q = query.trim().toLowerCase()
|
|
148
|
+
const list = q ? state.projects.filter((p) => p.name.toLowerCase().includes(q) || p.shown.toLowerCase().includes(q)) : state.projects
|
|
149
|
+
const groups = new Map()
|
|
150
|
+
for (const p of list) groups.set(p.root, [...(groups.get(p.root) ?? []), p])
|
|
151
|
+
return [...groups]
|
|
152
|
+
}, [state.projects, query])
|
|
153
|
+
|
|
154
|
+
const card = (p) =>
|
|
155
|
+
h(
|
|
156
|
+
"li",
|
|
157
|
+
{ key: p.path, className: "kh-pj-card" },
|
|
158
|
+
h(
|
|
159
|
+
"div",
|
|
160
|
+
{ className: "kh-pj-main" },
|
|
161
|
+
h("div", { className: "kh-pj-name", title: p.name }, p.name),
|
|
162
|
+
h("div", { className: "kh-pj-path", title: p.path }, h("bdi", null, p.shown)),
|
|
163
|
+
h(
|
|
164
|
+
"div",
|
|
165
|
+
{ className: "kh-pj-tags" },
|
|
166
|
+
p.here ? h("span", { className: "kh-pj-tag here" }, "started here") : null,
|
|
167
|
+
openPaths.has(p.path) ? h("span", { className: "kh-pj-tag" }, "in sidebar") : null,
|
|
168
|
+
p.git ? h("span", { className: "kh-pj-tag" }, "git") : null,
|
|
169
|
+
h("span", { className: "kh-pj-tag" }, since(p.modifiedAt))
|
|
170
|
+
)
|
|
171
|
+
),
|
|
172
|
+
h(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
type: "button",
|
|
176
|
+
className: "kh-pj-btn primary kh-pj-open",
|
|
177
|
+
disabled: opening !== "",
|
|
178
|
+
"aria-label": `Open ${p.name}`,
|
|
179
|
+
onClick: () => openProject(p),
|
|
180
|
+
},
|
|
181
|
+
opening === p.path ? "Opening…" : "Open"
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
return h(
|
|
186
|
+
"section",
|
|
187
|
+
{ className: "kh-pj", "aria-labelledby": "kh-pj-title" },
|
|
188
|
+
h(
|
|
189
|
+
"header",
|
|
190
|
+
{ className: "kh-pj-head" },
|
|
191
|
+
h(
|
|
192
|
+
"div",
|
|
193
|
+
null,
|
|
194
|
+
h("h1", { id: "kh-pj-title", className: "kh-pj-title" }, "Projects"),
|
|
195
|
+
h("p", { className: "kh-pj-sub" }, "Folders on this computer that look like projects. Open one and the agent starts a session there.")
|
|
196
|
+
),
|
|
197
|
+
h(
|
|
198
|
+
"div",
|
|
199
|
+
{ className: "kh-pj-tools" },
|
|
200
|
+
h("input", {
|
|
201
|
+
className: "kh-pj-search",
|
|
202
|
+
type: "search",
|
|
203
|
+
placeholder: "Search projects",
|
|
204
|
+
"aria-label": "Search projects",
|
|
205
|
+
value: query,
|
|
206
|
+
onChange: (e) => setQuery(e.target.value),
|
|
207
|
+
}),
|
|
208
|
+
h("button", { type: "button", className: "kh-pj-btn", onClick: load, disabled: state.loading }, state.loading ? "Looking…" : "Look again")
|
|
209
|
+
)
|
|
210
|
+
),
|
|
211
|
+
error || state.error ? h("p", { className: "kh-pj-error", role: "alert" }, error || state.error) : null,
|
|
212
|
+
h(
|
|
213
|
+
"div",
|
|
214
|
+
{ className: "kh-pj-body" },
|
|
215
|
+
!state.loading && state.projects.length === 0
|
|
216
|
+
? h(
|
|
217
|
+
"p",
|
|
218
|
+
{ className: "kh-pj-note" },
|
|
219
|
+
"No project folders found in ",
|
|
220
|
+
state.roots.length ? state.roots.join(", ") : "the usual places (~/Developer, ~/Projects, ~/code and others)",
|
|
221
|
+
". Add other folders with ",
|
|
222
|
+
h("code", null, "KRIYA_PROJECT_ROOTS"),
|
|
223
|
+
" (paths separated by colons) before starting kriya, or open any folder with the sidebar's folder button."
|
|
224
|
+
)
|
|
225
|
+
: shown.map(([root, list]) =>
|
|
226
|
+
h("div", { key: root }, h("div", { className: "kh-pj-group", title: root }, h("bdi", null, root)), h("ul", { className: "kh-pj-list" }, list.map(card)))
|
|
227
|
+
),
|
|
228
|
+
state.truncated ? h("p", { className: "kh-pj-note" }, "Showing the first projects found; search narrows the list.") : null
|
|
229
|
+
)
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ─────────────────────────────── apply ──────────────────────────────── */
|
|
235
|
+
|
|
236
|
+
const inject = ["slots", "workspaces", "uiWorkspace"]
|
|
237
|
+
|
|
238
|
+
function apply(ctx) {
|
|
239
|
+
if (typeof document !== "undefined") ctx.effect(installStyles, "kriya-projects: styles")
|
|
240
|
+
const ProjectsPage = makePage(ctx)
|
|
241
|
+
ctx.slots.inject("main", () => ctx.slots.register({ name: "main", key: PANEL_ID }, ProjectsPage))
|
|
242
|
+
ctx.slots.inject("sidebar.panellist", () =>
|
|
243
|
+
ctx.slots.register({ name: "sidebar.panellist", id: PANEL_ID, order: 4, label: "Projects" }, ProjectsIcon)
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return { apply, inject, makePage, ProjectsIcon, API, workspaceFor }
|
|
248
|
+
},
|
|
249
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { findProjects } from "../../src/projects.js"
|
|
2
|
+
|
|
3
|
+
// The Projects page, node half: one read-only route on DSH's shared /api
|
|
4
|
+
// channel, inside Connection's fence (Host/Origin checks, the signed browser
|
|
5
|
+
// cookie, owner Peers only), as the Skills page's routes are. The browser
|
|
6
|
+
// names nothing; it gets the list the Host finds.
|
|
7
|
+
|
|
8
|
+
export const name = "kriya-projects"
|
|
9
|
+
export const inject = ["connection"]
|
|
10
|
+
|
|
11
|
+
export const ROUTE = "/api/kriya.projects"
|
|
12
|
+
|
|
13
|
+
export function apply(ctx) {
|
|
14
|
+
const log = ctx.logger("kriya-projects")
|
|
15
|
+
ctx.effect(() =>
|
|
16
|
+
ctx.connection.fetch.register({
|
|
17
|
+
path: ROUTE,
|
|
18
|
+
methods: ["GET"],
|
|
19
|
+
requestBody: "buffered",
|
|
20
|
+
fetch: () => {
|
|
21
|
+
try {
|
|
22
|
+
return Response.json(findProjects(), { headers: { "cache-control": "no-store" } })
|
|
23
|
+
} catch (error) {
|
|
24
|
+
log.warn(error)
|
|
25
|
+
return Response.json({ error: "Kriya couldn't list the projects; see the terminal for details." }, { status: 500 })
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kriya-ai/harness-projects",
|
|
3
|
+
"description": "The Projects page of the Kriya Harness Web UI: the project folders on this computer, each opened as a workspace in a click",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.js",
|
|
10
|
+
"./client": "./client.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"dsh": {
|
|
14
|
+
"client": {
|
|
15
|
+
"inject": [
|
|
16
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
17
|
+
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
18
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
19
|
+
],
|
|
20
|
+
"platform": "web"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"license": "UNLICENSED"
|
|
24
|
+
}
|