@kriya-ai/harness 0.2.5 → 2.0.1

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 (134) hide show
  1. package/RELEASE_NOTES.md +121 -0
  2. package/SAFETY.md +181 -0
  3. package/THIRD_PARTY_NOTICES.md +113 -0
  4. package/bin/kriya.js +188 -2
  5. package/bundle/cordis.patch.yml +60 -5
  6. package/contract/SOURCE.md +3 -3
  7. package/contract/contract.json +498 -3
  8. package/contract/schemas/api.json +64 -0
  9. package/contract/schemas/auth_matrix.json +44 -0
  10. package/contract/schemas/component_states.json +33 -0
  11. package/contract/schemas/design_tokens.json +34 -0
  12. package/contract/schemas/scene_direction.json +82 -0
  13. package/contract/schemas/threat_model.json +44 -0
  14. package/package.json +2 -1
  15. package/plugins/changes/client.js +5 -3
  16. package/plugins/deploy/index.js +215 -0
  17. package/plugins/deploy/package.json +13 -0
  18. package/plugins/grounding/index.js +81 -0
  19. package/plugins/grounding/lookup.js +373 -0
  20. package/plugins/grounding/package.json +13 -0
  21. package/plugins/kriya-tools/index.js +2 -1
  22. package/plugins/loop/index.js +381 -10
  23. package/plugins/mcp/index.js +79 -0
  24. package/plugins/mcp/package.json +13 -0
  25. package/plugins/mirror/index.js +17 -0
  26. package/plugins/overview/client.js +5 -2
  27. package/plugins/preview/client.js +12 -6
  28. package/plugins/progress/client.js +7 -4
  29. package/plugins/repo/index.js +230 -0
  30. package/plugins/repo/package.json +13 -0
  31. package/plugins/repo/repo.js +348 -0
  32. package/plugins/runstrip/client.js +436 -0
  33. package/plugins/runstrip/index.js +312 -0
  34. package/plugins/runstrip/package.json +23 -0
  35. package/src/cartridges.js +133 -0
  36. package/src/contracts.js +130 -0
  37. package/src/critic.js +78 -0
  38. package/src/daemon.js +7 -1
  39. package/src/doctor.js +67 -0
  40. package/src/edit/core/effects.js +185 -0
  41. package/src/edit/core/ffmpeg.js +65 -6
  42. package/src/edit/core/layout.js +46 -1
  43. package/src/edit/core/ops.js +169 -2
  44. package/src/edit/core/plan.js +65 -9
  45. package/src/edit/core/project.d.ts +24 -0
  46. package/src/edit/core/project.js +64 -0
  47. package/src/edit/core/solver.js +34 -6
  48. package/src/edit/core/style-brief.js +211 -0
  49. package/src/edit/core/style-packs.js +57 -0
  50. package/src/edit/core/type-kit.js +173 -0
  51. package/src/edit/director/ask.js +37 -3
  52. package/src/edit/director/assembly.js +829 -0
  53. package/src/edit/director/continuity.js +9 -1
  54. package/src/edit/director/custom-motion.js +88 -0
  55. package/src/edit/director/graphics.js +44 -10
  56. package/src/edit/director/intent.js +125 -0
  57. package/src/edit/director/mentions.js +52 -0
  58. package/src/edit/director/plan.js +43 -11
  59. package/src/edit/director/revise.js +132 -9
  60. package/src/edit/director/viewer.js +136 -0
  61. package/src/edit/director/watch-fix.js +119 -0
  62. package/src/edit/engine/captions.js +110 -5
  63. package/src/edit/engine/confine.js +81 -4
  64. package/src/edit/engine/custom.js +243 -0
  65. package/src/edit/engine/dna2.js +893 -0
  66. package/src/edit/engine/fonts.js +218 -0
  67. package/src/edit/engine/graphics.js +271 -10
  68. package/src/edit/engine/index.js +14 -5
  69. package/src/edit/engine/motion.js +148 -13
  70. package/src/edit/engine/music-bed.js +59 -1
  71. package/src/edit/engine/packs.js +11 -0
  72. package/src/edit/engine/reference2.js +26 -0
  73. package/src/edit/engine/sfx.js +56 -1
  74. package/src/edit/engine/tool.js +21 -5
  75. package/src/edit/gates/assembly.js +194 -0
  76. package/src/edit/gates/copy.js +7 -4
  77. package/src/edit/gates/index.js +72 -7
  78. package/src/edit/gates/reference.js +115 -0
  79. package/src/edit/gates/tile.js +96 -0
  80. package/src/edit/host/client.js +8 -3
  81. package/src/edit/host/clips.js +33 -0
  82. package/src/edit/host/jobs.js +9 -3
  83. package/src/edit/host/layers.js +134 -0
  84. package/src/edit/host/main.js +10 -3
  85. package/src/edit/host/paths.js +21 -3
  86. package/src/edit/host/preview.js +108 -0
  87. package/src/edit/host/projects.js +443 -34
  88. package/src/edit/host/server.js +235 -20
  89. package/src/edit/host/tavi.js +77 -0
  90. package/src/edit/index/index.js +3 -2
  91. package/src/edit/loop/make.js +28 -3
  92. package/src/edit/recipes/assembly.js +352 -0
  93. package/src/edit/recipes/graphic-clips.js +4 -2
  94. package/src/edit/recipes/openings.js +36 -0
  95. package/src/edit/recipes/reel.js +104 -14
  96. package/src/edit/recipes/reference-look.js +29 -0
  97. package/src/edit/recipes/short-from-long.js +3 -3
  98. package/src/edit/recipes/sound.js +71 -0
  99. package/src/edit/runtime/cli.js +26 -5
  100. package/src/edit/runtime/fetch.js +4 -4
  101. package/src/edit/runtime/licences.js +7 -1
  102. package/src/explore.js +103 -0
  103. package/src/failure.js +1 -1
  104. package/src/gate-commands.js +114 -0
  105. package/src/gates/api.js +127 -0
  106. package/src/gates/commands.js +111 -0
  107. package/src/gates/detectors.js +370 -0
  108. package/src/gates/http.js +62 -0
  109. package/src/gates/index.js +196 -0
  110. package/src/gates/page.js +264 -0
  111. package/src/gates/sast.js +64 -0
  112. package/src/gates/stack.js +110 -0
  113. package/src/gates/tenant.js +162 -0
  114. package/src/gates/three.js +431 -0
  115. package/src/gates/ui.js +111 -0
  116. package/src/gateway-proxy.js +20 -2
  117. package/src/launch.js +39 -5
  118. package/src/loop.js +199 -7
  119. package/src/mcp.js +126 -0
  120. package/src/milestones.js +188 -0
  121. package/src/modes.js +67 -0
  122. package/src/orchestra.js +50 -0
  123. package/src/outcomes.js +88 -0
  124. package/src/profiles.js +5 -0
  125. package/src/receipts.js +238 -0
  126. package/src/release.js +356 -0
  127. package/src/runstrip.js +122 -0
  128. package/src/stack.js +120 -0
  129. package/src/verify.js +67 -20
  130. package/studio/dist/fonts/fraunces.woff2 +0 -0
  131. package/studio/dist/fonts/geist.woff2 +0 -0
  132. package/studio/dist/fonts/jetbrains-mono.woff2 +0 -0
  133. package/studio/dist/studio.css +449 -1
  134. package/studio/dist/studio.js +3 -3
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "design_tokens.json (W3C Design Tokens format, the subset Kriya checks)",
4
+ "type": "object",
5
+ "minProperties": 1,
6
+ "$defs": {
7
+ "group": {
8
+ "type": "object",
9
+ "properties": {
10
+ "$value": {},
11
+ "$type": {
12
+ "type": "string"
13
+ },
14
+ "$description": {
15
+ "type": "string"
16
+ },
17
+ "$extensions": {
18
+ "type": "object"
19
+ }
20
+ },
21
+ "additionalProperties": {
22
+ "$ref": "#/$defs/group"
23
+ }
24
+ }
25
+ },
26
+ "additionalProperties": {
27
+ "$ref": "#/$defs/group"
28
+ },
29
+ "properties": {
30
+ "$extensions": {
31
+ "type": "object"
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,82 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "scene_direction.json",
4
+ "description": "The designer's art direction for a 3D step (Kriya-Tavi docs/kriya-harness/upgrade_2.0/THREE_D_AND_CREATIVE.md §3). Budgets can only tighten the gate's code ceilings. References are words, never copied images or another work's assets.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["mood", "lighting", "toneMapping", "motion", "tiers", "routes"],
8
+ "$defs": {
9
+ "budget": {
10
+ "type": "object",
11
+ "additionalProperties": false,
12
+ "properties": {
13
+ "drawCalls": { "type": "integer", "minimum": 1 },
14
+ "triangles": { "type": "integer", "minimum": 1 },
15
+ "textureBytes": { "type": "integer", "minimum": 1 },
16
+ "routeBytes": { "type": "integer", "minimum": 1 }
17
+ }
18
+ },
19
+ "range": {
20
+ "type": "array",
21
+ "minItems": 2,
22
+ "maxItems": 2,
23
+ "items": { "type": "number", "minimum": 0, "maximum": 1 }
24
+ },
25
+ "path": { "type": "string", "pattern": "^/[^\\s]{0,200}$" }
26
+ },
27
+ "properties": {
28
+ "mood": { "type": "string", "minLength": 1, "maxLength": 200 },
29
+ "palette": { "type": "array", "maxItems": 24, "uniqueItems": true, "items": { "type": "string", "pattern": "^[A-Za-z0-9_.-]{1,60}$" } },
30
+ "lighting": { "enum": ["studio-product", "daylight-exterior", "night-neon", "soft-clay", "data-abstract"] },
31
+ "toneMapping": { "enum": ["agx", "aces", "neutral", "none"] },
32
+ "exposure": { "type": "number", "minimum": 0.05, "maximum": 8 },
33
+ "camera": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["fov"],
37
+ "properties": {
38
+ "fov": { "type": "number", "minimum": 10, "maximum": 120 },
39
+ "position": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "type": "number" } },
40
+ "target": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "type": "number" } }
41
+ }
42
+ },
43
+ "materials": {
44
+ "type": "object",
45
+ "additionalProperties": false,
46
+ "properties": { "metalness": { "$ref": "#/$defs/range" }, "roughness": { "$ref": "#/$defs/range" } }
47
+ },
48
+ "motion": { "enum": ["none", "subtle", "full"] },
49
+ "tiers": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "minProperties": 1,
53
+ "properties": { "low": { "$ref": "#/$defs/budget" }, "mid": { "$ref": "#/$defs/budget" }, "high": { "$ref": "#/$defs/budget" } }
54
+ },
55
+ "routes": {
56
+ "type": "array",
57
+ "minItems": 1,
58
+ "maxItems": 4,
59
+ "items": {
60
+ "type": "object",
61
+ "additionalProperties": false,
62
+ "required": ["path"],
63
+ "properties": { "path": { "$ref": "#/$defs/path" }, "unmount": { "$ref": "#/$defs/path" } }
64
+ }
65
+ },
66
+ "assets": {
67
+ "type": "array",
68
+ "maxItems": 200,
69
+ "items": {
70
+ "type": "object",
71
+ "additionalProperties": false,
72
+ "required": ["path", "licence", "source"],
73
+ "properties": {
74
+ "path": { "type": "string", "pattern": "^[^\\s/][^\\s]{0,300}$" },
75
+ "licence": { "type": "string", "minLength": 2, "maxLength": 60 },
76
+ "source": { "type": "string", "minLength": 2, "maxLength": 300 }
77
+ }
78
+ }
79
+ },
80
+ "references": { "type": "array", "maxItems": 8, "items": { "type": "string", "maxLength": 200 } }
81
+ }
82
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "threat_model.json",
4
+ "type": "array",
5
+ "maxItems": 300,
6
+ "items": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "required": [
10
+ "asset",
11
+ "boundary",
12
+ "threat",
13
+ "control",
14
+ "test"
15
+ ],
16
+ "properties": {
17
+ "asset": {
18
+ "type": "string",
19
+ "minLength": 1,
20
+ "maxLength": 300
21
+ },
22
+ "boundary": {
23
+ "type": "string",
24
+ "minLength": 1,
25
+ "maxLength": 300
26
+ },
27
+ "threat": {
28
+ "type": "string",
29
+ "minLength": 1,
30
+ "maxLength": 300
31
+ },
32
+ "control": {
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "maxLength": 300
36
+ },
37
+ "test": {
38
+ "type": "string",
39
+ "minLength": 1,
40
+ "maxLength": 300
41
+ }
42
+ }
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kriya-ai/harness",
3
- "version": "0.2.5",
3
+ "version": "2.0.1",
4
4
  "description": "Kriya Harness (beta): a Kriya agent on your machine, built on DeepSeek Harness",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,6 +21,7 @@
21
21
  "contract/",
22
22
  "studio/dist/",
23
23
  "SAFETY.md",
24
+ "RELEASE_NOTES.md",
24
25
  "THIRD_PARTY_NOTICES.md",
25
26
  "README.md"
26
27
  ],
@@ -12,6 +12,8 @@ window.__ModuleLoader__.load({
12
12
  const h = React.createElement
13
13
 
14
14
  const PLUGIN = "@kriya-ai/harness-changes"
15
+ // Harness 2.0 W18: with --runstrip, plugins/runstrip names the four tracks and adds each one's section; absent, nothing changes
16
+ const tracks = () => globalThis.__kriyaTracks
15
17
  const KIND = "kriya-changes"
16
18
  const API = { list: "api/kriya.changes", diff: "api/kriya.changes.diff" }
17
19
  // While the tab is on screen; a hidden tab doesn't poll
@@ -218,15 +220,15 @@ window.__ModuleLoader__.load({
218
220
  )),
219
221
  ]
220
222
 
221
- return h("div", { className: "kh-ch" }, head, body)
223
+ return h("div", { className: "kh-ch" }, head, tracks() && h(tracks().Changes, { sessionId }), body)
222
224
  }
223
225
 
224
226
  const definition = {
225
227
  id: PLUGIN,
226
228
  kind: KIND,
227
229
  priority: "extension",
228
- title: () => "Changes",
229
- guide: [{ id: "changes", order: 15, title: () => "Changes", description: () => "What changed in this folder, file by file", icon: ChangesIcon }],
230
+ title: () => tracks()?.title[KIND] ?? "Changes",
231
+ guide: [{ id: "changes", get order() { return tracks()?.order[KIND] ?? 15 }, title: () => tracks()?.title[KIND] ?? "Changes", description: () => "What changed in this folder, file by file", icon: ChangesIcon }],
230
232
  }
231
233
 
232
234
  const inject = ["slots", "sidebarRightTabs"]
@@ -0,0 +1,215 @@
1
+ import { defineTool } from "@deepseek-ai/dsh-tools"
2
+
3
+ import { runner } from "../repo/repo.js"
4
+ import { forPerson, gDeployed, gRelease, personsOnly, productionAllowed, readRelease, readState, recordReady, recordSmoke, ReleaseError } from "../../src/release.js"
5
+ import { projectRoot } from "../../src/skill-switches.js"
6
+
7
+ // Harness 2.0 W17, deploy (Kriya-Tavi docs/kriya-harness/upgrade_2.0/
8
+ // DELIVERY_AND_STABILITY.md; WD-21, WD-22). release_check runs G-RELEASE;
9
+ // deploy_preview and deploy_production run the provider's own CLI, signed in
10
+ // by the person (no credential read), each after the person approves the
11
+ // exact provider, target, commit and command; Auto, Read only and Full access
12
+ // refuse. The deployment URL is captured from the CLI's output by code and
13
+ // must match the provider's host (or the person's confirmed domain), else no
14
+ // smoke runs. Production needs a passing release check and a passing preview
15
+ // smoke of the same commit. A guard refuses, in the agent's own shell, the
16
+ // commands that are the person's alone (WD-22) and writes them down for them.
17
+ // Off unless kriya was started with --deploy (KRIYA_DEPLOY=on).
18
+
19
+ export const name = "kriya-deploy"
20
+ export const inject = ["tools", "workingDirectory", "shell", "shellEnv"]
21
+
22
+ const OBJECT = { schema: { type: "object", additionalProperties: true, properties: {} } }
23
+ const DECLINED = "The person didn't approve it (in Auto, Read only or Full access mode Kriya can't ask, so it refuses: use Ask mode)."
24
+
25
+ /**
26
+ * Adapters whose CLI behaviour spike S1 confirmed from the provider's own
27
+ * documentation (2026-11-23). Vercel: "When deploying, stdout is the
28
+ * Deployment URL" (JSON in non-interactive mode, which still contains it);
29
+ * `--prod` for production; `--yes` skips setup questions; `vercel rollback`.
30
+ * Netlify, Cloudflare Pages and Fly.io weren't confirmed (their pages don't
31
+ * say how the URL is printed), so they aren't shipped.
32
+ */
33
+ export const ADAPTERS = {
34
+ vercel: {
35
+ cli: "vercel",
36
+ preview: ["deploy", "--yes"],
37
+ production: ["deploy", "--prod", "--yes"],
38
+ rollback: ["rollback"],
39
+ host: /^[a-z0-9-]+\.vercel\.app$/,
40
+ },
41
+ }
42
+
43
+ /** The deployment URL from a CLI's output: the first https URL whose host is the provider's or the confirmed domain. */
44
+ export function captureUrl(output, adapter, domain) {
45
+ for (const m of String(output ?? "").matchAll(/https:\/\/[^\s"'<>\\]+/g)) {
46
+ let url
47
+ try {
48
+ url = new URL(m[0])
49
+ } catch {
50
+ continue
51
+ }
52
+ const host = url.hostname.toLowerCase()
53
+ if (!url.username && !url.password && (adapter.host.test(host) || (domain && host === domain))) return `https://${url.host}/`
54
+ }
55
+ return undefined
56
+ }
57
+
58
+ /** The guard for the agent's shells (WD-22): a reason denies the call. */
59
+ export function personsOnlyGuard(record) {
60
+ return (exec) => {
61
+ if (!["bash", "pwsh", "terminal", "run_code"].includes(exec?.name)) return undefined
62
+ const args = exec.arguments && typeof exec.arguments === "object" ? exec.arguments : {}
63
+ const command = [args.command, args.code, args.input].find((v) => typeof v === "string")
64
+ const why = personsOnly(command)
65
+ if (!why) return undefined
66
+ record?.(command, why, exec)
67
+ return `Kriya never runs this: it ${why}. That's the person's to do; it was written down for them (kriya receipt, the release notes for this project). Tell them, and go on with the rest.`
68
+ }
69
+ }
70
+
71
+ export function deployTools(host) {
72
+ const run = host.runCli ?? runner()
73
+ const git = async (root, args) => (await run("git", args, root)).stdout.trim()
74
+ const rootOf = async (exec) => {
75
+ if (!exec.agent) throw new ReleaseError("This tool needs a session.")
76
+ return projectRoot(await host.cwd(exec))
77
+ }
78
+ const cleanCommit = async (root) => {
79
+ if (await git(root, ["status", "--porcelain"])) throw new ReleaseError("There are uncommitted changes. A release is checked and deployed from a commit: commit first.")
80
+ const commit = await git(root, ["rev-parse", "--verify", "-q", "HEAD"])
81
+ if (!/^[0-9a-f]{40}$/.test(commit)) throw new ReleaseError("No commit to release yet.")
82
+ return commit
83
+ }
84
+ // The release diff: the commits since the default branch (or everything), added lines per file
85
+ const releaseFiles = async (root) => {
86
+ const base = (await git(root, ["merge-base", "HEAD", "origin/HEAD"])) || (await git(root, ["merge-base", "HEAD", "main"])) || "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
87
+ const text = (await run("git", ["diff", "--no-color", "--no-ext-diff", "-U0", base, "HEAD"], root)).stdout
88
+ const files = []
89
+ let current
90
+ for (const line of text.split("\n")) {
91
+ const f = /^\+\+\+ b\/(.+)$/.exec(line)
92
+ if (f) files.push((current = { path: f[1], content: "", added: [] }))
93
+ const h = /^@@ -\d+(?:,\d+)? \+(\d+)/.exec(line)
94
+ if (h && current) current.next = Number(h[1])
95
+ else if (current && line.startsWith("+") && !line.startsWith("+++")) current.added.push({ line: current.next++, text: line.slice(1) })
96
+ }
97
+ return files
98
+ }
99
+ const adapterOf = (root) => {
100
+ const release = readRelease(root)
101
+ const id = release?.provider ?? "vercel"
102
+ const adapter = ADAPTERS[id]
103
+ if (!adapter) throw new ReleaseError(`No confirmed adapter for ${id}.`)
104
+ return { id, adapter, release }
105
+ }
106
+ async function deploy(exec, target) {
107
+ const root = await rootOf(exec)
108
+ if (host.readOnly(exec)) throw new ReleaseError("Read only mode deploys nothing.")
109
+ const commit = await cleanCommit(root)
110
+ if (target === "production") {
111
+ const allowed = productionAllowed(root, commit)
112
+ if (!allowed.ok) throw new ReleaseError(allowed.why)
113
+ }
114
+ const { id, adapter, release } = adapterOf(root)
115
+ const argv = adapter[target]
116
+ if (!(await host.approve(exec, `Deploy ${target} with ${id}: \`${adapter.cli} ${argv.join(" ")}\` of commit ${commit.slice(0, 12)} in this project`))) throw new ReleaseError(DECLINED)
117
+ const out = await run(adapter.cli, argv, root)
118
+ if (out.missing) throw new ReleaseError(`The ${id} CLI isn't installed. The person installs it and signs in (${adapter.cli} login) in a terminal.`)
119
+ if (out.code !== 0) throw new ReleaseError(`${adapter.cli} exited ${out.code}: ${String(out.stderr || out.stdout).trim().split("\n").slice(-3).join(" ").slice(0, 400)}`)
120
+ const url = captureUrl(`${out.stdout}\n${out.stderr}`, adapter, release?.domain)
121
+ if (!url) {
122
+ recordSmoke(root, { target, commit, ok: false, url: null, note: "URL not confirmed" })
123
+ return { target, commit, url: null, smoke: "not run: no deployment URL on the provider's host was printed, so nothing was checked" }
124
+ }
125
+ const smoke = await gDeployed(url, release, { fetchImpl: host.fetch })
126
+ recordSmoke(root, { target, commit, ok: smoke.status === "pass", host: smoke.host, requests: smoke.requests })
127
+ const result = { target, commit, url, smoke }
128
+ if (target === "production" && smoke.status !== "pass") {
129
+ // Offered, never automatic: the person approves the rollback; it's always written down for them
130
+ const rollback = `${adapter.cli} ${adapter.rollback.join(" ")}`
131
+ forPerson(root, rollback, "rolls production back after a failed smoke check")
132
+ if (await host.approve(exec, `The production smoke check failed. Roll back with \`${rollback}\`?`)) {
133
+ const back = await run(adapter.cli, adapter.rollback, root)
134
+ result.rollback = back.code === 0 ? "rolled back" : `rollback failed (${back.code}); the person runs ${rollback}`
135
+ } else result.rollback = `not run; the person can run ${rollback}`
136
+ }
137
+ return result
138
+ }
139
+ return [
140
+ defineTool({
141
+ name: "release_check",
142
+ description: "Run G-RELEASE on the current commit: the confirmed production build, the confirmed production server's pages (G-UI, G-A11Y), environment variables named in .env.example, bundle budget, lockfile and licences, migrations and secrets. Ready only when every line passes.",
143
+ parameters: {},
144
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: `${v.ready ? "Ready" : "Not ready"} (commit ${v.commit.slice(0, 12)}):\n${v.lines.map((l) => `${l.status === "pass" ? "✓" : l.status === "fail" ? "✗" : "–"} ${l.id}${l.detail ? `: ${l.detail}` : ""}`).join("\n")}` }] },
145
+ async execute(_args, exec) {
146
+ const root = await rootOf(exec)
147
+ const commit = await cleanCommit(root)
148
+ const result = await gRelease(root, { run: (command) => host.runCheck(exec, command, root), files: () => releaseFiles(root), commit: async () => commit, ...(host.rendered && { rendered: host.rendered }) })
149
+ recordReady(root, result.commit, result.ready, result.lines)
150
+ return result
151
+ },
152
+ presentCall: () => ({ card: "generic", title: "Release check", kind: "execute", rawInput: "" }),
153
+ }),
154
+ defineTool({
155
+ name: "deploy_preview",
156
+ description: "Deploy the current commit as a preview with the project's provider CLI (the person approves it), then check the printed URL with G-DEPLOYED.",
157
+ parameters: {},
158
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: JSON.stringify(v, null, 2) }] },
159
+ execute: (_args, exec) => deploy(exec, "preview"),
160
+ presentCall: () => ({ card: "generic", title: "Deploy a preview", kind: "execute", rawInput: "" }),
161
+ }),
162
+ defineTool({
163
+ name: "deploy_production",
164
+ description: "Deploy the current commit to production (only after release_check passed and a preview of the same commit passed its smoke check; the person approves it), then check the production URL. A failed check offers a rollback.",
165
+ parameters: {},
166
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: JSON.stringify(v, null, 2) }] },
167
+ execute: (_args, exec) => deploy(exec, "production"),
168
+ presentCall: () => ({ card: "generic", title: "Deploy to production", kind: "execute", rawInput: "" }),
169
+ }),
170
+ defineTool({
171
+ name: "release_status",
172
+ description: "The project's release records: the latest release check and smoke checks per commit, and the commands left for the person.",
173
+ parameters: {},
174
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: JSON.stringify(v, null, 2) }] },
175
+ async execute(_args, exec) {
176
+ const state = readState(await rootOf(exec))
177
+ return { records: state.records.slice(-10), forPerson: state.forPerson ?? [] }
178
+ },
179
+ presentCall: () => ({ card: "generic", title: "Release status", kind: "read", rawInput: "" }),
180
+ }),
181
+ ]
182
+ }
183
+
184
+ export function apply(ctx) {
185
+ const sandboxPolicy = ctx.get("sandboxPolicy")
186
+ const folders = new WeakMap()
187
+ const host = {
188
+ async cwd(exec) {
189
+ const cwd = await ctx.workingDirectory.ensure(exec.agent, exec.signal)
190
+ folders.set(exec.agent, cwd)
191
+ return cwd
192
+ },
193
+ readOnly: (exec) => sandboxPolicy?.resolve({ session: exec.agent?.session })?.mode === "read-only",
194
+ approve: async (exec, reason) =>
195
+ (await ctx.get("approval").request({ agent: exec.agent, toolName: exec.name ?? "kriya_deploy", callId: exec.callId, reason, signal: exec.signal })) === "allowed-once",
196
+ // The confirmed build runs the way the person's check does: under the session's sandbox
197
+ async runCheck(exec, command, workdir) {
198
+ const policy = sandboxPolicy?.resolve({ session: exec.agent.session })
199
+ const spec = ctx.shell.resolve({ command, workdir, timeoutMs: 15 * 60_000, dshEnv: ctx.shellEnv.collect(exec), ...(policy !== undefined && { sandboxPolicy: policy }), signal: exec.signal })
200
+ const result = await (await ctx.shell.execute(spec)).result()
201
+ return { exitCode: result.exitCode, timedOut: result.timedOut, output: [result.stdout.text, result.stderr.text].filter(Boolean).join("\n") }
202
+ },
203
+ }
204
+ for (const tool of deployTools(host)) ctx.tools.register(tool)
205
+ ctx.tools.guard(
206
+ personsOnlyGuard((command, why, exec) => {
207
+ try {
208
+ const cwd = folders.get(exec.agent) ?? exec.agent?.session?.header?.cwd ?? process.cwd()
209
+ forPerson(projectRoot(cwd), command, why)
210
+ } catch {
211
+ // Writing it down is best effort; the refusal stands either way
212
+ }
213
+ })
214
+ )
215
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@kriya-ai/harness-deploy",
3
+ "description": "G-RELEASE, preview and production deploys through the person's own provider CLI with approval, G-DEPLOYED, and the commands that stay the person's",
4
+ "version": "0.1.0",
5
+ "private": true,
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "license": "UNLICENSED"
13
+ }
@@ -0,0 +1,81 @@
1
+ import { defineTool } from "@deepseek-ai/dsh-tools"
2
+
3
+ import { projectRoot } from "../../src/skill-switches.js"
4
+ import { apiChanges, apiLookup, apiVersion, GroundingError, hasInstalled } from "./lookup.js"
5
+
6
+ // Harness 2.0 W15, grounding (Kriya-Tavi docs/kriya-harness/upgrade_2.0/
7
+ // GROUNDING_AND_CONNECTORS.md §5, WD-20): three read-only tools that answer
8
+ // facts about the packages this project has installed from their own files,
9
+ // and one line in a late system-prompt section naming them. Cheap models fail
10
+ // most on APIs that moved in the installed version; these give the fact
11
+ // instead of another guess. Nothing is imported or executed, nothing leaves
12
+ // the machine. Off unless kriya was started with --grounding
13
+ // (KRIYA_GROUNDING=on): off, no tool or section exists.
14
+
15
+ export const name = "kriya-grounding"
16
+ export const inject = ["tools", "workingDirectory", "systemPrompt"]
17
+
18
+ const OBJECT = { schema: { type: "object", additionalProperties: true, properties: {} } }
19
+ const PACKAGE = { type: "string", required: true, description: "The package's name as installed, e.g. react, @supabase/supabase-js, requests." }
20
+
21
+ export const HINT =
22
+ "Before calling a package's API you aren't sure of, check the installed version's facts: api_lookup (a signature and its doc comment), api_changes (what changed since the version the project declares) and api_version. They read the project's own installed files, so they're exact for this project."
23
+
24
+ export function groundingTools(host) {
25
+ const guarded = (fn) => async (args, exec) => {
26
+ if (!exec.agent) throw new GroundingError("This tool needs a session.")
27
+ return fn(projectRoot(await host.cwd(exec)), args ?? {})
28
+ }
29
+ return [
30
+ defineTool({
31
+ name: "api_lookup",
32
+ description: "The installed version's declaration of an exported name in a package, with its doc comment: from its TypeScript type definitions (or @types), or Python .pyi stubs. Reads files only.",
33
+ parameters: { package: PACKAGE, symbol: { type: "string", required: true, description: "The exported name, e.g. createClient, useEffect, Session." } },
34
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: v.text }] },
35
+ execute: guarded((root, args) => apiLookup(root, args.package, args.symbol)),
36
+ presentCall: (args) => ({ card: "generic", title: "Look up an API", kind: "read", rawInput: `${args.package ?? ""} ${args.symbol ?? ""}`.trim() }),
37
+ }),
38
+ defineTool({
39
+ name: "api_changes",
40
+ description: "What changed in a package between the version the project declares (or `since`) and the one installed, from the package's own changelog.",
41
+ parameters: { package: PACKAGE, since: { type: "string", description: "The version the code was written for, if not the declared one, e.g. 4.2.0." } },
42
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: v.text }] },
43
+ execute: guarded((root, args) => apiChanges(root, args.package, args.since)),
44
+ presentCall: (args) => ({ card: "generic", title: "Package changes", kind: "read", rawInput: String(args.package ?? "") }),
45
+ }),
46
+ defineTool({
47
+ name: "api_version",
48
+ description: "A package's declared range, locked version and installed version in this project.",
49
+ parameters: { package: PACKAGE },
50
+ output: { ...OBJECT, render: (_a, v) => [{ type: "text", text: [`${v.package}:`, v.declared && `declared ${v.declared}`, v.locked && `locked ${v.locked}`, v.installed ? `installed ${v.installed}` : (v.note ?? "not installed")].filter(Boolean).join(" ") }] },
51
+ execute: guarded((root, args) => apiVersion(root, args.package)),
52
+ presentCall: (args) => ({ card: "generic", title: "Package version", kind: "read", rawInput: String(args.package ?? "") }),
53
+ }),
54
+ ]
55
+ }
56
+
57
+ export function apply(ctx) {
58
+ const folders = new WeakMap()
59
+ const host = {
60
+ async cwd(exec) {
61
+ const cwd = await ctx.workingDirectory.ensure(exec.agent, exec.signal)
62
+ folders.set(exec.agent, cwd)
63
+ return cwd
64
+ },
65
+ }
66
+ for (const tool of groundingTools(host)) ctx.tools.register(tool)
67
+ // One line, late (after DSH's suffix), only in a project with installed packages
68
+ ctx.systemPrompt.section({
69
+ name: "kriya:grounding",
70
+ order: 10260,
71
+ interpolate: false,
72
+ text: ({ scope }) => {
73
+ const cwd = scope && (folders.get(scope) ?? scope.session?.header?.cwd)
74
+ try {
75
+ return cwd && hasInstalled(projectRoot(cwd)) ? HINT : ""
76
+ } catch {
77
+ return ""
78
+ }
79
+ },
80
+ })
81
+ }