opencode-agent-skill 15.0.0 → 15.1.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.
- package/README.md +5 -5
- package/docs/V15-MANAGED-RUNTIME.md +18 -0
- package/global-config/agents/verifier.md +6 -2
- package/lib/affected-tests.mjs +58 -8
- package/lib/capability-fabric.mjs +107 -48
- package/lib/code-intelligence/index.mjs +4 -15
- package/lib/code-intelligence/lsp-pool.mjs +694 -0
- package/lib/code-intelligence/lsp-provider.mjs +481 -67
- package/lib/compaction-resume-guard.mjs +327 -0
- package/lib/completion-auditor.mjs +20 -0
- package/lib/context-engine-v11.mjs +20 -7
- package/lib/context-manifest.mjs +38 -21
- package/lib/decision-policy.mjs +40 -2
- package/lib/evidence-store.mjs +121 -31
- package/lib/executable-probe.mjs +69 -0
- package/lib/execution-contract.mjs +29 -16
- package/lib/hierarchical-context.mjs +31 -3
- package/lib/learning-engine.mjs +164 -65
- package/lib/memory-engine.mjs +348 -98
- package/lib/model-config.mjs +86 -7
- package/lib/performance-fabric.mjs +354 -107
- package/lib/permission-policy.mjs +232 -0
- package/lib/pi-rpc-pool.mjs +170 -5
- package/lib/provider-recovery.mjs +51 -0
- package/lib/repo-graph.mjs +38 -5
- package/lib/runtime-events.mjs +31 -10
- package/lib/semantic-index.mjs +67 -20
- package/lib/skill-compiler.mjs +84 -18
- package/lib/subagent-artifacts.mjs +182 -0
- package/lib/task-policy.mjs +80 -7
- package/lib/trajectory.mjs +25 -1
- package/lib/untrusted-output.mjs +106 -0
- package/lib/verification-broker.mjs +32 -27
- package/lib/workspace-fingerprint.mjs +43 -8
- package/lib/workspace-hygiene.mjs +481 -0
- package/package.json +8 -6
- package/pi/extensions/ues-child-runtime.ts +103 -5
- package/pi/extensions/ues.ts +984 -95
- package/scripts/benchmark-lsp-pool.mjs +128 -0
- package/scripts/check-release-consistency.mjs +16 -4
- package/scripts/check-source-integrity.mjs +60 -1
- package/scripts/run-test-suite.mjs +143 -0
- package/scripts/smoke-package-closure.mjs +4 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
import { existsSync, lstatSync, readFileSync, readlinkSync } from "node:fs"
|
|
3
|
+
import { rm } from "node:fs/promises"
|
|
4
|
+
import { spawnSync } from "node:child_process"
|
|
5
|
+
import path from "node:path"
|
|
6
|
+
import { decodeTextBuffer } from "./text-encoding.mjs"
|
|
7
|
+
import { isUesRuntimeArtifactPath, sourceFacingPaths } from "./runtime-artifacts.mjs"
|
|
8
|
+
|
|
9
|
+
const CODE_EXTENSIONS = new Set([
|
|
10
|
+
".js", ".cjs", ".mjs", ".jsx", ".ts", ".cts", ".mts", ".tsx",
|
|
11
|
+
".py", ".pyi", ".java", ".kt", ".kts", ".go", ".rs", ".c", ".h",
|
|
12
|
+
".cc", ".cpp", ".cxx", ".hpp", ".cs", ".php", ".rb", ".swift",
|
|
13
|
+
".scala", ".vue", ".svelte", ".html", ".htm", ".css", ".scss", ".sass",
|
|
14
|
+
".less", ".json", ".jsonc", ".yaml", ".yml", ".toml", ".xml", ".sql",
|
|
15
|
+
".graphql", ".gql", ".sh", ".bash", ".zsh", ".ps1", ".cmd", ".bat",
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
const CODE_BASENAMES = new Set([
|
|
19
|
+
"dockerfile", "makefile", "rakefile", "gemfile", "procfile",
|
|
20
|
+
".eslintrc", ".prettierrc", ".babelrc",
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
const KNOWN_SCRATCH = Object.freeze([
|
|
24
|
+
".ues-cache/fast-acceptance.test.mjs",
|
|
25
|
+
".ues-cache/tmp",
|
|
26
|
+
".ues-cache/scratch",
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
function normalizePath(value) {
|
|
30
|
+
return String(value || "").replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/^\/+/, "")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function withinRoot(root, relative) {
|
|
34
|
+
const resolvedRoot = path.resolve(root)
|
|
35
|
+
const file = path.resolve(resolvedRoot, relative)
|
|
36
|
+
if (file !== resolvedRoot && !file.startsWith(resolvedRoot + path.sep)) {
|
|
37
|
+
throw new Error("workspace hygiene path escapes root: " + relative)
|
|
38
|
+
}
|
|
39
|
+
return file
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function fileState(root, relative) {
|
|
43
|
+
const normalized = normalizePath(relative)
|
|
44
|
+
if (!normalized) return { exists: false, kind: "missing", size: 0, hash: null }
|
|
45
|
+
let file
|
|
46
|
+
try {
|
|
47
|
+
file = withinRoot(root, normalized)
|
|
48
|
+
} catch {
|
|
49
|
+
return { exists: false, kind: "escape", size: 0, hash: null }
|
|
50
|
+
}
|
|
51
|
+
if (!existsSync(file)) return { exists: false, kind: "missing", size: 0, hash: null }
|
|
52
|
+
try {
|
|
53
|
+
const info = lstatSync(file)
|
|
54
|
+
if (info.isSymbolicLink()) {
|
|
55
|
+
const target = readlinkSync(file)
|
|
56
|
+
return {
|
|
57
|
+
exists: true,
|
|
58
|
+
kind: "symlink",
|
|
59
|
+
size: Buffer.byteLength(target),
|
|
60
|
+
hash: createHash("sha256").update(target).digest("hex"),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (info.isFile()) {
|
|
64
|
+
const bytes = readFileSync(file)
|
|
65
|
+
return {
|
|
66
|
+
exists: true,
|
|
67
|
+
kind: "file",
|
|
68
|
+
size: bytes.length,
|
|
69
|
+
hash: createHash("sha256").update(bytes).digest("hex"),
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (info.isDirectory()) return { exists: true, kind: "directory", size: 0, hash: null }
|
|
73
|
+
return { exists: true, kind: "other", size: Number(info.size || 0), hash: null }
|
|
74
|
+
} catch {
|
|
75
|
+
return { exists: false, kind: "unreadable", size: 0, hash: null }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function sameState(left, right) {
|
|
80
|
+
return Boolean(left) && Boolean(right) &&
|
|
81
|
+
left.exists === right.exists &&
|
|
82
|
+
left.kind === right.kind &&
|
|
83
|
+
Number(left.size || 0) === Number(right.size || 0) &&
|
|
84
|
+
String(left.hash || "") === String(right.hash || "")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function parseGitStatusEntries(statusOutput) {
|
|
88
|
+
const tokens = String(statusOutput || "").split("\0").filter(Boolean)
|
|
89
|
+
const rows = []
|
|
90
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
91
|
+
const token = tokens[index]
|
|
92
|
+
if (token.length < 3 || token[2] !== " ") continue
|
|
93
|
+
const status = token.slice(0, 2)
|
|
94
|
+
const current = normalizePath(token.slice(3))
|
|
95
|
+
let original = null
|
|
96
|
+
if (/[RC]/.test(status) && index + 1 < tokens.length) {
|
|
97
|
+
original = normalizePath(tokens[index + 1])
|
|
98
|
+
index += 1
|
|
99
|
+
}
|
|
100
|
+
if (current && !isUesRuntimeArtifactPath(current)) rows.push({ status, path: current, originalPath: original })
|
|
101
|
+
}
|
|
102
|
+
return rows
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function gitStatusEntries(root, workspaceState = null) {
|
|
106
|
+
const resolved = path.resolve(root)
|
|
107
|
+
if (
|
|
108
|
+
workspaceState &&
|
|
109
|
+
typeof workspaceState === "object" &&
|
|
110
|
+
workspaceState.root &&
|
|
111
|
+
path.resolve(workspaceState.root) === resolved &&
|
|
112
|
+
typeof workspaceState.statusOutput === "string"
|
|
113
|
+
) {
|
|
114
|
+
return parseGitStatusEntries(workspaceState.statusOutput)
|
|
115
|
+
}
|
|
116
|
+
const result = spawnSync("git", ["status", "--porcelain=v1", "-z", "--untracked-files=all"], {
|
|
117
|
+
cwd: resolved,
|
|
118
|
+
encoding: "utf8",
|
|
119
|
+
windowsHide: true,
|
|
120
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
121
|
+
})
|
|
122
|
+
if (result.status !== 0) {
|
|
123
|
+
throw new Error(String(result.stderr || result.stdout || "git status failed").trim())
|
|
124
|
+
}
|
|
125
|
+
return parseGitStatusEntries(result.stdout)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function snapshotDirty(root, workspaceState = null) {
|
|
129
|
+
const rows = gitStatusEntries(root, workspaceState)
|
|
130
|
+
const paths = sourceFacingPaths(rows.flatMap((row) => [row.path, row.originalPath].filter(Boolean))).sort()
|
|
131
|
+
const entries = {}
|
|
132
|
+
for (const relative of paths) {
|
|
133
|
+
const row = rows.find((item) => item.path === relative || item.originalPath === relative)
|
|
134
|
+
entries[relative] = {
|
|
135
|
+
status: row?.status || "??",
|
|
136
|
+
state: fileState(root, relative),
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return { paths, entries }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function captureWorkspaceHygieneBaseline(root = process.cwd(), options = {}) {
|
|
143
|
+
const resolved = path.resolve(root)
|
|
144
|
+
const dirty = snapshotDirty(resolved, options.workspaceState || null)
|
|
145
|
+
const scratch = {}
|
|
146
|
+
for (const relative of KNOWN_SCRATCH) {
|
|
147
|
+
scratch[relative] = fileState(resolved, relative)
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
schemaVersion: 1,
|
|
151
|
+
root: resolved,
|
|
152
|
+
capturedAt: new Date().toISOString(),
|
|
153
|
+
paths: dirty.paths,
|
|
154
|
+
entries: dirty.entries,
|
|
155
|
+
scratch,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function isAuditableSourcePath(relative) {
|
|
160
|
+
const normalized = normalizePath(relative)
|
|
161
|
+
if (!normalized || isUesRuntimeArtifactPath(normalized)) return false
|
|
162
|
+
const base = path.posix.basename(normalized).toLowerCase()
|
|
163
|
+
const ext = path.posix.extname(base).toLowerCase()
|
|
164
|
+
return CODE_EXTENSIONS.has(ext) || CODE_BASENAMES.has(base)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function locationAt(text, utf16Index) {
|
|
168
|
+
const prefix = String(text || "").slice(0, Math.max(0, utf16Index))
|
|
169
|
+
const rows = prefix.split("\n")
|
|
170
|
+
return {
|
|
171
|
+
line: rows.length,
|
|
172
|
+
column: [...(rows.at(-1) || "")].length + 1,
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function codePointLabel(cp) {
|
|
177
|
+
return "U+" + cp.toString(16).toUpperCase().padStart(4, "0")
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function finding(file, kind, message, index, text, codePoint = null) {
|
|
181
|
+
const loc = locationAt(text, index)
|
|
182
|
+
return {
|
|
183
|
+
severity: "error",
|
|
184
|
+
blocking: true,
|
|
185
|
+
file: normalizePath(file),
|
|
186
|
+
kind,
|
|
187
|
+
line: loc.line,
|
|
188
|
+
column: loc.column,
|
|
189
|
+
codePoint: codePoint == null ? null : codePointLabel(codePoint),
|
|
190
|
+
message,
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function auditUnicodeSource(text, options = {}) {
|
|
195
|
+
const source = String(text ?? "")
|
|
196
|
+
const file = normalizePath(options.file || "<memory>")
|
|
197
|
+
const findings = []
|
|
198
|
+
let utf16Index = 0
|
|
199
|
+
|
|
200
|
+
for (const char of source) {
|
|
201
|
+
const cp = char.codePointAt(0)
|
|
202
|
+
const width = char.length
|
|
203
|
+
const isAllowedWhitespace = cp === 0x09 || cp === 0x0a || cp === 0x0d
|
|
204
|
+
if ((cp < 0x20 && !isAllowedWhitespace) || (cp >= 0x7f && cp <= 0x9f)) {
|
|
205
|
+
findings.push(finding(file, "control-character", "Unexpected control character in source", utf16Index, source, cp))
|
|
206
|
+
} else if (cp === 0xfffd) {
|
|
207
|
+
findings.push(finding(file, "replacement-character", "Unicode replacement character indicates corrupted or lossy text", utf16Index, source, cp))
|
|
208
|
+
} else if (cp === 0xfeff && utf16Index !== 0) {
|
|
209
|
+
findings.push(finding(file, "embedded-bom", "BOM/zero-width no-break space is only allowed at the start of a file", utf16Index, source, cp))
|
|
210
|
+
} else if (
|
|
211
|
+
cp === 0x200b || cp === 0x200c || cp === 0x200d || cp === 0x2060 ||
|
|
212
|
+
cp === 0x180e
|
|
213
|
+
) {
|
|
214
|
+
findings.push(finding(file, "zero-width-character", "Invisible zero-width/joining character is not allowed in audited source", utf16Index, source, cp))
|
|
215
|
+
} else if (
|
|
216
|
+
(cp >= 0x202a && cp <= 0x202e) ||
|
|
217
|
+
(cp >= 0x2066 && cp <= 0x2069)
|
|
218
|
+
) {
|
|
219
|
+
findings.push(finding(file, "bidi-control", "Bidirectional override/isolate control is blocked to prevent visually misleading source", utf16Index, source, cp))
|
|
220
|
+
}
|
|
221
|
+
utf16Index += width
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const identifierLike = /[\p{L}_$][\p{L}\p{N}\p{Mn}\p{Mc}_$]*/gu
|
|
225
|
+
for (const match of source.matchAll(identifierLike)) {
|
|
226
|
+
const token = match[0]
|
|
227
|
+
const latin = /\p{Script=Latin}/u.test(token)
|
|
228
|
+
const cyrillic = /\p{Script=Cyrillic}/u.test(token)
|
|
229
|
+
const greek = /\p{Script=Greek}/u.test(token)
|
|
230
|
+
if (latin && (cyrillic || greek)) {
|
|
231
|
+
findings.push(finding(
|
|
232
|
+
file,
|
|
233
|
+
"mixed-script-token",
|
|
234
|
+
"Token mixes Latin with Cyrillic/Greek characters and may contain a homoglyph",
|
|
235
|
+
Number(match.index || 0),
|
|
236
|
+
source,
|
|
237
|
+
null,
|
|
238
|
+
))
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
schemaVersion: 1,
|
|
244
|
+
file,
|
|
245
|
+
safe: findings.length === 0,
|
|
246
|
+
findings,
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function auditUnicodeFiles(root, files, options = {}) {
|
|
251
|
+
const reports = []
|
|
252
|
+
const maxBytes = Math.max(64 * 1024, Math.min(Number(options.maxBytes || 4 * 1024 * 1024), 16 * 1024 * 1024))
|
|
253
|
+
for (const relative of sourceFacingPaths(files).filter(isAuditableSourcePath)) {
|
|
254
|
+
const absolute = withinRoot(root, relative)
|
|
255
|
+
if (!existsSync(absolute)) continue
|
|
256
|
+
const info = lstatSync(absolute)
|
|
257
|
+
if (!info.isFile()) continue
|
|
258
|
+
if (info.size > maxBytes) {
|
|
259
|
+
reports.push({
|
|
260
|
+
schemaVersion: 1,
|
|
261
|
+
file: relative,
|
|
262
|
+
safe: false,
|
|
263
|
+
findings: [{
|
|
264
|
+
severity: "error",
|
|
265
|
+
blocking: true,
|
|
266
|
+
file: relative,
|
|
267
|
+
kind: "source-too-large",
|
|
268
|
+
line: null,
|
|
269
|
+
column: null,
|
|
270
|
+
codePoint: null,
|
|
271
|
+
message: `Changed source exceeds hygiene audit byte limit (${info.size} > ${maxBytes})`,
|
|
272
|
+
}],
|
|
273
|
+
})
|
|
274
|
+
continue
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const text = decodeTextBuffer(readFileSync(absolute))
|
|
278
|
+
reports.push(auditUnicodeSource(text, { file: relative }))
|
|
279
|
+
} catch (error) {
|
|
280
|
+
reports.push({
|
|
281
|
+
schemaVersion: 1,
|
|
282
|
+
file: relative,
|
|
283
|
+
safe: false,
|
|
284
|
+
findings: [{
|
|
285
|
+
severity: "error",
|
|
286
|
+
blocking: true,
|
|
287
|
+
file: relative,
|
|
288
|
+
kind: "text-decode-failed",
|
|
289
|
+
line: null,
|
|
290
|
+
column: null,
|
|
291
|
+
codePoint: null,
|
|
292
|
+
message: error instanceof Error ? error.message : String(error),
|
|
293
|
+
}],
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
safe: reports.every((report) => report.safe),
|
|
299
|
+
reports,
|
|
300
|
+
findings: reports.flatMap((report) => report.findings || []),
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function classifyTransientArtifact(relative) {
|
|
305
|
+
const normalized = normalizePath(relative)
|
|
306
|
+
const lower = normalized.toLowerCase()
|
|
307
|
+
const base = path.posix.basename(lower)
|
|
308
|
+
|
|
309
|
+
if (
|
|
310
|
+
/\.(?:tmp|temp|swp|swo|orig|rej|bak)$/.test(base) ||
|
|
311
|
+
/~$/.test(base) ||
|
|
312
|
+
[".ds_store", "thumbs.db", "npm-debug.log", "yarn-debug.log", "yarn-error.log", "pnpm-debug.log"].includes(base) ||
|
|
313
|
+
/(?:^|\/)(?:__pycache__|\.pytest_cache|\.mypy_cache|\.ruff_cache|coverage|test-results|playwright-report)(?:\/|$)/.test(lower)
|
|
314
|
+
) {
|
|
315
|
+
return { transient: true, confidence: "high", reason: "known-generated-or-temporary-artifact" }
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (
|
|
319
|
+
/^(?:debug|scratch|tmp|temp|trial|experiment|playground|test-try|try)[-_.]/.test(base)
|
|
320
|
+
) {
|
|
321
|
+
return { transient: true, confidence: "suspicious", reason: "debug-scratch-or-generated-output-name" }
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return { transient: false, confidence: "none", reason: null }
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function taskMentionsPath(taskText, relative) {
|
|
328
|
+
const task = String(taskText || "").toLowerCase().replaceAll("\\", "/")
|
|
329
|
+
const normalized = normalizePath(relative).toLowerCase()
|
|
330
|
+
const base = path.posix.basename(normalized)
|
|
331
|
+
return Boolean(
|
|
332
|
+
normalized && task.includes(normalized) ||
|
|
333
|
+
base.length >= 4 && task.includes(base)
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async function cleanupScratchCreatedAfterBaseline(root, baseline) {
|
|
338
|
+
const removed = []
|
|
339
|
+
for (const relative of KNOWN_SCRATCH) {
|
|
340
|
+
const before = baseline?.scratch?.[relative]
|
|
341
|
+
const after = fileState(root, relative)
|
|
342
|
+
if (after.exists && !before?.exists) {
|
|
343
|
+
const target = withinRoot(root, relative)
|
|
344
|
+
await rm(target, { recursive: true, force: true })
|
|
345
|
+
if (!existsSync(target)) removed.push(relative)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return removed
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async function removeHighConfidenceCreatedArtifacts(root, createdPaths, taskText) {
|
|
352
|
+
const removed = []
|
|
353
|
+
for (const relative of createdPaths) {
|
|
354
|
+
const classification = classifyTransientArtifact(relative)
|
|
355
|
+
if (!classification.transient || classification.confidence !== "high") continue
|
|
356
|
+
if (taskMentionsPath(taskText, relative)) continue
|
|
357
|
+
const target = withinRoot(root, relative)
|
|
358
|
+
await rm(target, { recursive: true, force: true }).catch(() => {})
|
|
359
|
+
if (!existsSync(target)) removed.push(relative)
|
|
360
|
+
}
|
|
361
|
+
return removed
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function deltaFromBaseline(root, baseline) {
|
|
365
|
+
const current = snapshotDirty(root)
|
|
366
|
+
const beforeEntries = baseline?.entries || {}
|
|
367
|
+
const all = new Set([...(baseline?.paths || []), ...current.paths])
|
|
368
|
+
const changed = []
|
|
369
|
+
const created = []
|
|
370
|
+
|
|
371
|
+
for (const relative of all) {
|
|
372
|
+
const before = beforeEntries[relative]?.state || null
|
|
373
|
+
const nowEntry = current.entries[relative] || null
|
|
374
|
+
const after = nowEntry?.state || fileState(root, relative)
|
|
375
|
+
if (before && sameState(before, after)) continue
|
|
376
|
+
if (!before && !nowEntry) continue
|
|
377
|
+
changed.push(relative)
|
|
378
|
+
const status = String(nowEntry?.status || "")
|
|
379
|
+
if (!before && (status === "??" || status.startsWith("A"))) created.push(relative)
|
|
380
|
+
}
|
|
381
|
+
return { current, changed: sourceFacingPaths(changed), created: sourceFacingPaths(created) }
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function renderFinding(item) {
|
|
385
|
+
const where = item.line ? `:${item.line}:${item.column || 1}` : ""
|
|
386
|
+
const codePoint = item.codePoint ? ` ${item.codePoint}` : ""
|
|
387
|
+
return `${item.file}${where} [${item.kind}]${codePoint} ${item.message}`
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async function auditWorkspaceDelta(root, options = {}) {
|
|
391
|
+
const baseline = options.baseline || captureWorkspaceHygieneBaseline(root)
|
|
392
|
+
let delta = deltaFromBaseline(root, baseline)
|
|
393
|
+
const removedScratch = options.autoClean === false
|
|
394
|
+
? []
|
|
395
|
+
: await cleanupScratchCreatedAfterBaseline(root, baseline)
|
|
396
|
+
const removedTransient = options.autoClean === false
|
|
397
|
+
? []
|
|
398
|
+
: await removeHighConfidenceCreatedArtifacts(root, delta.created, options.taskText)
|
|
399
|
+
if (removedScratch.length || removedTransient.length) delta = deltaFromBaseline(root, baseline)
|
|
400
|
+
|
|
401
|
+
const unicode = await auditUnicodeFiles(root, delta.changed, options)
|
|
402
|
+
const artifactFindings = []
|
|
403
|
+
for (const relative of delta.created) {
|
|
404
|
+
const classification = classifyTransientArtifact(relative)
|
|
405
|
+
if (!classification.transient) continue
|
|
406
|
+
if (classification.confidence === "high" && removedTransient.includes(relative)) continue
|
|
407
|
+
if (taskMentionsPath(options.taskText, relative)) continue
|
|
408
|
+
artifactFindings.push({
|
|
409
|
+
severity: "error",
|
|
410
|
+
blocking: true,
|
|
411
|
+
file: relative,
|
|
412
|
+
kind: "unexplained-transient-artifact",
|
|
413
|
+
line: null,
|
|
414
|
+
column: null,
|
|
415
|
+
codePoint: null,
|
|
416
|
+
message: `New file looks like a debug/scratch/generated artifact (${classification.reason})`,
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const allowed = new Set(sourceFacingPaths(options.allowedPaths || []))
|
|
421
|
+
const scopeFindings = options.strictScope === true
|
|
422
|
+
? delta.changed
|
|
423
|
+
.filter((relative) => !allowed.has(relative))
|
|
424
|
+
.map((relative) => ({
|
|
425
|
+
severity: "error",
|
|
426
|
+
blocking: true,
|
|
427
|
+
file: relative,
|
|
428
|
+
kind: "undeclared-source-change",
|
|
429
|
+
line: null,
|
|
430
|
+
column: null,
|
|
431
|
+
codePoint: null,
|
|
432
|
+
message: "Source changed outside the declared final write scope",
|
|
433
|
+
}))
|
|
434
|
+
: []
|
|
435
|
+
|
|
436
|
+
const readOnlyFindings = options.allowSourceMutations === false && delta.changed.length
|
|
437
|
+
? delta.changed.map((relative) => ({
|
|
438
|
+
severity: "error",
|
|
439
|
+
blocking: true,
|
|
440
|
+
file: relative,
|
|
441
|
+
kind: "read-only-agent-mutation",
|
|
442
|
+
line: null,
|
|
443
|
+
column: null,
|
|
444
|
+
codePoint: null,
|
|
445
|
+
message: "Read-only specialist mutated source/runtime-visible project files",
|
|
446
|
+
}))
|
|
447
|
+
: []
|
|
448
|
+
|
|
449
|
+
const findings = [
|
|
450
|
+
...unicode.findings,
|
|
451
|
+
...artifactFindings,
|
|
452
|
+
...scopeFindings,
|
|
453
|
+
...readOnlyFindings,
|
|
454
|
+
]
|
|
455
|
+
return {
|
|
456
|
+
schemaVersion: 1,
|
|
457
|
+
safe: findings.length === 0,
|
|
458
|
+
changed: delta.changed,
|
|
459
|
+
created: delta.created,
|
|
460
|
+
removed: [...removedScratch, ...removedTransient],
|
|
461
|
+
unicode,
|
|
462
|
+
findings,
|
|
463
|
+
summary: findings.length
|
|
464
|
+
? findings.slice(0, 20).map(renderFinding).join("\n")
|
|
465
|
+
: `workspace hygiene PASS; changed=${delta.changed.length}; cleaned=${removedScratch.length + removedTransient.length}`,
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export async function postRunFileHygiene(root, options = {}) {
|
|
470
|
+
return auditWorkspaceDelta(path.resolve(root), {
|
|
471
|
+
...options,
|
|
472
|
+
autoClean: options.autoClean !== false,
|
|
473
|
+
})
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export async function preFinalWorkspaceAudit(root, options = {}) {
|
|
477
|
+
return auditWorkspaceDelta(path.resolve(root), {
|
|
478
|
+
...options,
|
|
479
|
+
autoClean: false,
|
|
480
|
+
})
|
|
481
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-agent-skill",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.1.1",
|
|
4
4
|
"description": "Pi-native UES coding-agent runtime with adaptive stability, Turbo Fast Path, durable verification, managed services, and weak-model orchestration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"syntax": "node scripts/syntax-check.mjs",
|
|
32
|
-
"test": "node
|
|
33
|
-
"test:pi": "node
|
|
32
|
+
"test": "node scripts/run-test-suite.mjs",
|
|
33
|
+
"test:pi": "node scripts/run-test-suite.mjs --concurrency=1 --timeout-ms=90000 test/pi-package.test.mjs",
|
|
34
34
|
"docs:check": "node scripts/check-release-consistency.mjs",
|
|
35
35
|
"release:check-tag": "node scripts/check-release-tag.mjs",
|
|
36
36
|
"smoke:pi": "node scripts/smoke-pi-extension.mjs",
|
|
@@ -39,11 +39,13 @@
|
|
|
39
39
|
"ci": "npm run integrity && npm run runtime:exports && npm run syntax && npm test && npm run docs:check && npm pack --dry-run && npm run smoke:pi && npm run smoke:package && npm run smoke:packed",
|
|
40
40
|
"prepublishOnly": "npm run ci",
|
|
41
41
|
"smoke:packed": "node scripts/smoke-packed-install.mjs",
|
|
42
|
-
"eval:v14": "node
|
|
42
|
+
"eval:v14": "node scripts/run-test-suite.mjs --concurrency=4 --timeout-ms=90000 test/capability-fabric-v14.test.mjs test/hierarchical-context-v14.test.mjs test/memory-engine-v14.test.mjs test/context-engine-v14.test.mjs test/task-engine-v14-context.test.mjs test/cli-v14.test.mjs test/v14-contract.test.mjs test/performance-fabric-v14.test.mjs test/browser-mcp-routing-v14.test.mjs test/process-hang-detector-v14.test.mjs test/v14.2-runtime.test.mjs test/benchmark-confidence.test.mjs test/v14.3-intelligence.test.mjs",
|
|
43
43
|
"integrity": "node scripts/check-source-integrity.mjs",
|
|
44
44
|
"runtime:exports": "node scripts/check-runtime-exports.mjs",
|
|
45
|
-
"eval:v15": "node --test test/v15-runtime.test.mjs test/trajectory.test.mjs test/evidence-store-v11.test.mjs test/runtime-events.test.mjs test/v14.3-intelligence.test.mjs test/v14.2-runtime.test.mjs test/pi-package.test.mjs test/execution-contract.test.mjs",
|
|
46
|
-
"release:verify": "npm run ci && npm run eval:v15"
|
|
45
|
+
"eval:v15": "node scripts/run-test-suite.mjs --concurrency=4 --timeout-ms=90000 test/lsp-pool-v2.test.mjs test/v15-runtime.test.mjs test/provider-recovery.test.mjs test/semantic-index.test.mjs test/performance-fabric-v2.test.mjs test/pi-rpc-control.test.mjs test/trajectory.test.mjs test/evidence-store-v11.test.mjs test/runtime-events.test.mjs test/v14.3-intelligence.test.mjs test/v14.2-runtime.test.mjs test/pi-package.test.mjs test/execution-contract.test.mjs",
|
|
46
|
+
"release:verify": "npm run ci && npm run eval:v15",
|
|
47
|
+
"bench:lsp": "node scripts/benchmark-lsp-pool.mjs",
|
|
48
|
+
"test:node": "node --test"
|
|
47
49
|
},
|
|
48
50
|
"keywords": [
|
|
49
51
|
"pi-package",
|