@earendil-works/pi-agent-core 0.84.4 → 0.85.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 +4 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +9 -0
- package/dist/agent-loop.js.map +1 -1
- package/dist/harness/agent-harness.d.ts +639 -384
- package/dist/harness/agent-harness.d.ts.map +1 -1
- package/dist/harness/agent-harness.js +5 -251
- package/dist/harness/agent-harness.js.map +1 -1
- package/dist/harness/compaction/branch-summarization.d.ts +12 -6
- package/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/harness/compaction/branch-summarization.js +33 -26
- package/dist/harness/compaction/branch-summarization.js.map +1 -1
- package/dist/harness/compaction/compaction.d.ts +30 -8
- package/dist/harness/compaction/compaction.d.ts.map +1 -1
- package/dist/harness/compaction/compaction.js +53 -63
- package/dist/harness/compaction/compaction.js.map +1 -1
- package/dist/harness/config.d.ts +9 -0
- package/dist/harness/config.d.ts.map +1 -0
- package/dist/harness/config.js +27 -0
- package/dist/harness/config.js.map +1 -0
- package/dist/harness/context.d.ts +9 -0
- package/dist/harness/context.d.ts.map +1 -0
- package/dist/harness/context.js +13 -0
- package/dist/harness/context.js.map +1 -0
- package/dist/harness/env/nodejs.d.ts +24 -28
- package/dist/harness/env/nodejs.d.ts.map +1 -1
- package/dist/harness/env/nodejs.js +239 -86
- package/dist/harness/env/nodejs.js.map +1 -1
- package/dist/harness/events.d.ts +20 -38
- package/dist/harness/events.d.ts.map +1 -1
- package/dist/harness/events.js +240 -55
- package/dist/harness/events.js.map +1 -1
- package/dist/harness/execution/assistant.d.ts +42 -0
- package/dist/harness/execution/assistant.d.ts.map +1 -0
- package/dist/harness/execution/assistant.js +82 -0
- package/dist/harness/execution/assistant.js.map +1 -0
- package/dist/harness/execution/effect-gate.d.ts +22 -0
- package/dist/harness/execution/effect-gate.d.ts.map +1 -0
- package/dist/harness/execution/effect-gate.js +49 -0
- package/dist/harness/execution/effect-gate.js.map +1 -0
- package/dist/harness/execution/tools.d.ts +67 -0
- package/dist/harness/execution/tools.d.ts.map +1 -0
- package/dist/harness/execution/tools.js +121 -0
- package/dist/harness/execution/tools.js.map +1 -0
- package/dist/harness/hooks.d.ts +38 -0
- package/dist/harness/hooks.d.ts.map +1 -0
- package/dist/harness/hooks.js +406 -0
- package/dist/harness/hooks.js.map +1 -0
- package/dist/harness/messages.d.ts +2 -2
- package/dist/harness/messages.d.ts.map +1 -1
- package/dist/harness/messages.js.map +1 -1
- package/dist/harness/prompt-templates.d.ts +3 -2
- package/dist/harness/prompt-templates.d.ts.map +1 -1
- package/dist/harness/prompt-templates.js +17 -17
- package/dist/harness/prompt-templates.js.map +1 -1
- package/dist/harness/result.d.ts +93 -0
- package/dist/harness/result.d.ts.map +1 -1
- package/dist/harness/result.js +40 -0
- package/dist/harness/result.js.map +1 -1
- package/dist/harness/runtime/drive/boundary.d.ts +28 -0
- package/dist/harness/runtime/drive/boundary.d.ts.map +1 -0
- package/dist/harness/runtime/drive/boundary.js +170 -0
- package/dist/harness/runtime/drive/boundary.js.map +1 -0
- package/dist/harness/runtime/drive/checkpoint.d.ts +8 -0
- package/dist/harness/runtime/drive/checkpoint.d.ts.map +1 -0
- package/dist/harness/runtime/drive/checkpoint.js +133 -0
- package/dist/harness/runtime/drive/checkpoint.js.map +1 -0
- package/dist/harness/runtime/drive/deferred.d.ts +15 -0
- package/dist/harness/runtime/drive/deferred.d.ts.map +1 -0
- package/dist/harness/runtime/drive/deferred.js +179 -0
- package/dist/harness/runtime/drive/deferred.js.map +1 -0
- package/dist/harness/runtime/drive/generation.d.ts +8 -0
- package/dist/harness/runtime/drive/generation.d.ts.map +1 -0
- package/dist/harness/runtime/drive/generation.js +205 -0
- package/dist/harness/runtime/drive/generation.js.map +1 -0
- package/dist/harness/runtime/drive/reconcile.d.ts +5 -0
- package/dist/harness/runtime/drive/reconcile.d.ts.map +1 -0
- package/dist/harness/runtime/drive/reconcile.js +140 -0
- package/dist/harness/runtime/drive/reconcile.js.map +1 -0
- package/dist/harness/runtime/drive/recovery.d.ts +8 -0
- package/dist/harness/runtime/drive/recovery.d.ts.map +1 -0
- package/dist/harness/runtime/drive/recovery.js +85 -0
- package/dist/harness/runtime/drive/recovery.js.map +1 -0
- package/dist/harness/runtime/drive/response.d.ts +23 -0
- package/dist/harness/runtime/drive/response.d.ts.map +1 -0
- package/dist/harness/runtime/drive/response.js +394 -0
- package/dist/harness/runtime/drive/response.js.map +1 -0
- package/dist/harness/runtime/drive/retry.d.ts +4 -0
- package/dist/harness/runtime/drive/retry.d.ts.map +1 -0
- package/dist/harness/runtime/drive/retry.js +37 -0
- package/dist/harness/runtime/drive/retry.js.map +1 -0
- package/dist/harness/runtime/drive/structural.d.ts +32 -0
- package/dist/harness/runtime/drive/structural.d.ts.map +1 -0
- package/dist/harness/runtime/drive/structural.js +929 -0
- package/dist/harness/runtime/drive/structural.js.map +1 -0
- package/dist/harness/runtime/drive/terminal.d.ts +7 -0
- package/dist/harness/runtime/drive/terminal.d.ts.map +1 -0
- package/dist/harness/runtime/drive/terminal.js +49 -0
- package/dist/harness/runtime/drive/terminal.js.map +1 -0
- package/dist/harness/runtime/drive/tool-placement.d.ts +14 -0
- package/dist/harness/runtime/drive/tool-placement.d.ts.map +1 -0
- package/dist/harness/runtime/drive/tool-placement.js +244 -0
- package/dist/harness/runtime/drive/tool-placement.js.map +1 -0
- package/dist/harness/runtime/drive/tools.d.ts +6 -0
- package/dist/harness/runtime/drive/tools.d.ts.map +1 -0
- package/dist/harness/runtime/drive/tools.js +449 -0
- package/dist/harness/runtime/drive/tools.js.map +1 -0
- package/dist/harness/runtime/drive.d.ts +6 -0
- package/dist/harness/runtime/drive.d.ts.map +1 -0
- package/dist/harness/runtime/drive.js +93 -0
- package/dist/harness/runtime/drive.js.map +1 -0
- package/dist/harness/runtime/harness.d.ts +59 -0
- package/dist/harness/runtime/harness.d.ts.map +1 -0
- package/dist/harness/runtime/harness.js +311 -0
- package/dist/harness/runtime/harness.js.map +1 -0
- package/dist/harness/runtime/index.d.ts +2 -0
- package/dist/harness/runtime/index.d.ts.map +1 -0
- package/dist/harness/runtime/index.js +2 -0
- package/dist/harness/runtime/index.js.map +1 -0
- package/dist/harness/runtime/lane.d.ts +101 -0
- package/dist/harness/runtime/lane.d.ts.map +1 -0
- package/dist/harness/runtime/lane.js +1575 -0
- package/dist/harness/runtime/lane.js.map +1 -0
- package/dist/harness/runtime/progress.d.ts +15 -0
- package/dist/harness/runtime/progress.d.ts.map +1 -0
- package/dist/harness/runtime/progress.js +66 -0
- package/dist/harness/runtime/progress.js.map +1 -0
- package/dist/harness/runtime/reducer.d.ts +5 -0
- package/dist/harness/runtime/reducer.d.ts.map +1 -0
- package/dist/harness/runtime/reducer.js +240 -0
- package/dist/harness/runtime/reducer.js.map +1 -0
- package/dist/harness/runtime/restore.d.ts +24 -0
- package/dist/harness/runtime/restore.d.ts.map +1 -0
- package/dist/harness/runtime/restore.js +117 -0
- package/dist/harness/runtime/restore.js.map +1 -0
- package/dist/harness/runtime/transcript.d.ts +21 -0
- package/dist/harness/runtime/transcript.d.ts.map +1 -0
- package/dist/harness/runtime/transcript.js +72 -0
- package/dist/harness/runtime/transcript.js.map +1 -0
- package/dist/harness/runtime/types.d.ts +105 -0
- package/dist/harness/runtime/types.d.ts.map +1 -0
- package/dist/harness/runtime/types.js +61 -0
- package/dist/harness/runtime/types.js.map +1 -0
- package/dist/harness/session/commit.d.ts +53 -0
- package/dist/harness/session/commit.d.ts.map +1 -0
- package/dist/harness/session/commit.js +57 -0
- package/dist/harness/session/commit.js.map +1 -0
- package/dist/harness/session/context.d.ts +6 -18
- package/dist/harness/session/context.d.ts.map +1 -1
- package/dist/harness/session/context.js +31 -49
- package/dist/harness/session/context.js.map +1 -1
- package/dist/harness/session/fork-policy.d.ts +13 -0
- package/dist/harness/session/fork-policy.d.ts.map +1 -0
- package/dist/harness/session/fork-policy.js +22 -0
- package/dist/harness/session/fork-policy.js.map +1 -0
- package/dist/harness/session/fork.d.ts +18 -0
- package/dist/harness/session/fork.d.ts.map +1 -0
- package/dist/harness/session/fork.js +127 -0
- package/dist/harness/session/fork.js.map +1 -0
- package/dist/harness/session/in-memory-storage-state.d.ts +39 -0
- package/dist/harness/session/in-memory-storage-state.d.ts.map +1 -0
- package/dist/harness/session/in-memory-storage-state.js +216 -0
- package/dist/harness/session/in-memory-storage-state.js.map +1 -0
- package/dist/harness/session/index.d.ts +9 -5
- package/dist/harness/session/index.d.ts.map +1 -1
- package/dist/harness/session/index.js +7 -4
- package/dist/harness/session/index.js.map +1 -1
- package/dist/harness/session/jsonl/codec.d.ts +19 -8
- package/dist/harness/session/jsonl/codec.d.ts.map +1 -1
- package/dist/harness/session/jsonl/codec.js +34 -218
- package/dist/harness/session/jsonl/codec.js.map +1 -1
- package/dist/harness/session/jsonl/index.d.ts +4 -0
- package/dist/harness/session/jsonl/index.d.ts.map +1 -0
- package/dist/harness/session/jsonl/index.js +4 -0
- package/dist/harness/session/jsonl/index.js.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts +18 -0
- package/dist/harness/session/jsonl/legacy-v3.d.ts.map +1 -0
- package/dist/harness/session/jsonl/legacy-v3.js +383 -0
- package/dist/harness/session/jsonl/legacy-v3.js.map +1 -0
- package/dist/harness/session/jsonl/repo.d.ts +26 -19
- package/dist/harness/session/jsonl/repo.d.ts.map +1 -1
- package/dist/harness/session/jsonl/repo.js +266 -156
- package/dist/harness/session/jsonl/repo.js.map +1 -1
- package/dist/harness/session/jsonl/storage.d.ts +39 -41
- package/dist/harness/session/jsonl/storage.d.ts.map +1 -1
- package/dist/harness/session/jsonl/storage.js +238 -181
- package/dist/harness/session/jsonl/storage.js.map +1 -1
- package/dist/harness/session/jsonl/types.d.ts +23 -22
- package/dist/harness/session/jsonl/types.d.ts.map +1 -1
- package/dist/harness/session/jsonl/types.js +2 -1
- package/dist/harness/session/jsonl/types.js.map +1 -1
- package/dist/harness/session/memory.d.ts +46 -40
- package/dist/harness/session/memory.d.ts.map +1 -1
- package/dist/harness/session/memory.js +346 -113
- package/dist/harness/session/memory.js.map +1 -1
- package/dist/harness/session/mutation-line.d.ts +8 -0
- package/dist/harness/session/mutation-line.d.ts.map +1 -0
- package/dist/harness/session/mutation-line.js +21 -0
- package/dist/harness/session/mutation-line.js.map +1 -0
- package/dist/harness/session/session.d.ts +78 -46
- package/dist/harness/session/session.d.ts.map +1 -1
- package/dist/harness/session/session.js +343 -209
- package/dist/harness/session/session.js.map +1 -1
- package/dist/harness/session/testing/benchmark/datasets.d.ts +12 -0
- package/dist/harness/session/testing/benchmark/datasets.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/datasets.js +24 -0
- package/dist/harness/session/testing/benchmark/datasets.js.map +1 -0
- package/dist/harness/session/testing/benchmark/session-repo.d.ts +42 -0
- package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/session-repo.js +127 -0
- package/dist/harness/session/testing/benchmark/session-repo.js.map +1 -0
- package/dist/harness/session/testing/benchmark/storage.d.ts +25 -0
- package/dist/harness/session/testing/benchmark/storage.d.ts.map +1 -0
- package/dist/harness/session/testing/benchmark/storage.js +114 -0
- package/dist/harness/session/testing/benchmark/storage.js.map +1 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts +21 -0
- package/dist/harness/session/testing/conformance/session-repo.d.ts.map +1 -0
- package/dist/harness/session/testing/conformance/session-repo.js +590 -0
- package/dist/harness/session/testing/conformance/session-repo.js.map +1 -0
- package/dist/harness/session/testing/conformance/storage.d.ts +4 -0
- package/dist/harness/session/testing/conformance/storage.d.ts.map +1 -0
- package/dist/harness/session/testing/conformance/storage.js +600 -0
- package/dist/harness/session/testing/conformance/storage.js.map +1 -0
- package/dist/harness/session/testing/gating-storage.d.ts +26 -0
- package/dist/harness/session/testing/gating-storage.d.ts.map +1 -0
- package/dist/harness/session/testing/gating-storage.js +100 -0
- package/dist/harness/session/testing/gating-storage.js.map +1 -0
- package/dist/harness/session/testing/index.d.ts +9 -2
- package/dist/harness/session/testing/index.d.ts.map +1 -1
- package/dist/harness/session/testing/index.js +8 -1
- package/dist/harness/session/testing/index.js.map +1 -1
- package/dist/harness/session/testing/instrumented-storage.d.ts +11 -0
- package/dist/harness/session/testing/instrumented-storage.d.ts.map +1 -0
- package/dist/harness/session/testing/instrumented-storage.js +16 -0
- package/dist/harness/session/testing/instrumented-storage.js.map +1 -0
- package/dist/harness/session/testing/storage-decorator.d.ts +20 -0
- package/dist/harness/session/testing/storage-decorator.d.ts.map +1 -0
- package/dist/harness/session/testing/storage-decorator.js +41 -0
- package/dist/harness/session/testing/storage-decorator.js.map +1 -0
- package/dist/harness/session/testing/types.d.ts +5 -7
- package/dist/harness/session/testing/types.d.ts.map +1 -1
- package/dist/harness/session/testing/types.js.map +1 -1
- package/dist/harness/session/types.d.ts +424 -259
- package/dist/harness/session/types.d.ts.map +1 -1
- package/dist/harness/session/types.js +7 -8
- package/dist/harness/session/types.js.map +1 -1
- package/dist/harness/session/values.d.ts +95 -0
- package/dist/harness/session/values.d.ts.map +1 -0
- package/dist/harness/session/values.js +81 -0
- package/dist/harness/session/values.js.map +1 -0
- package/dist/harness/skills.d.ts +3 -2
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +29 -26
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/telemetry.d.ts +64 -43
- package/dist/harness/telemetry.d.ts.map +1 -1
- package/dist/harness/telemetry.js +45 -26
- package/dist/harness/telemetry.js.map +1 -1
- package/dist/harness/tools/bash.d.ts +4 -4
- package/dist/harness/tools/bash.d.ts.map +1 -1
- package/dist/harness/tools/bash.js +66 -93
- package/dist/harness/tools/bash.js.map +1 -1
- package/dist/harness/tools/edit.d.ts.map +1 -1
- package/dist/harness/tools/edit.js +10 -10
- package/dist/harness/tools/edit.js.map +1 -1
- package/dist/harness/tools/file-mutation-queue.d.ts +2 -1
- package/dist/harness/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/harness/tools/file-mutation-queue.js +5 -5
- package/dist/harness/tools/file-mutation-queue.js.map +1 -1
- package/dist/harness/tools/path-utils.d.ts +3 -2
- package/dist/harness/tools/path-utils.d.ts.map +1 -1
- package/dist/harness/tools/path-utils.js +5 -5
- package/dist/harness/tools/path-utils.js.map +1 -1
- package/dist/harness/tools/read.d.ts +2 -1
- package/dist/harness/tools/read.d.ts.map +1 -1
- package/dist/harness/tools/read.js +4 -6
- package/dist/harness/tools/read.js.map +1 -1
- package/dist/harness/tools/write.d.ts.map +1 -1
- package/dist/harness/tools/write.js +7 -7
- package/dist/harness/tools/write.js.map +1 -1
- package/dist/harness/types.d.ts +108 -45
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/utils/adaptive-publisher.d.ts +24 -0
- package/dist/harness/utils/adaptive-publisher.d.ts.map +1 -0
- package/dist/harness/utils/adaptive-publisher.js +79 -0
- package/dist/harness/utils/adaptive-publisher.js.map +1 -0
- package/dist/harness/utils/output-capture.d.ts +31 -0
- package/dist/harness/utils/output-capture.d.ts.map +1 -0
- package/dist/harness/utils/output-capture.js +217 -0
- package/dist/harness/utils/output-capture.js.map +1 -0
- package/dist/harness/utils/shell-output.d.ts +12 -5
- package/dist/harness/utils/shell-output.d.ts.map +1 -1
- package/dist/harness/utils/shell-output.js +64 -174
- package/dist/harness/utils/shell-output.js.map +1 -1
- package/dist/harness/utils/truncate.d.ts +1 -0
- package/dist/harness/utils/truncate.d.ts.map +1 -1
- package/dist/harness/utils/truncate.js +1 -1
- package/dist/harness/utils/truncate.js.map +1 -1
- package/dist/harness/utils/usage.d.ts +4 -0
- package/dist/harness/utils/usage.d.ts.map +1 -0
- package/dist/harness/utils/usage.js +33 -0
- package/dist/harness/utils/usage.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/proxy.d.ts +2 -0
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +40 -10
- package/dist/proxy.js.map +1 -1
- package/dist/search/index.d.ts +24 -16
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +1 -1
- package/dist/search/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +25 -4
- package/dist/harness/reducer.d.ts +0 -100
- package/dist/harness/reducer.d.ts.map +0 -1
- package/dist/harness/reducer.js +0 -415
- package/dist/harness/reducer.js.map +0 -1
- package/dist/harness/session/jsonl/errors.d.ts +0 -9
- package/dist/harness/session/jsonl/errors.d.ts.map +0 -1
- package/dist/harness/session/jsonl/errors.js +0 -19
- package/dist/harness/session/jsonl/errors.js.map +0 -1
- package/dist/harness/session/jsonl.d.ts +0 -3
- package/dist/harness/session/jsonl.d.ts.map +0 -1
- package/dist/harness/session/jsonl.js +0 -2
- package/dist/harness/session/jsonl.js.map +0 -1
- package/dist/harness/session/state.d.ts +0 -65
- package/dist/harness/session/state.d.ts.map +0 -1
- package/dist/harness/session/state.js +0 -319
- package/dist/harness/session/state.js.map +0 -1
- package/dist/harness/session/testing/conformance.d.ts +0 -4
- package/dist/harness/session/testing/conformance.d.ts.map +0 -1
- package/dist/harness/session/testing/conformance.js +0 -762
- package/dist/harness/session/testing/conformance.js.map +0 -1
- package/dist/search/scanning.d.ts +0 -29
- package/dist/search/scanning.d.ts.map +0 -1
- package/dist/search/scanning.js +0 -103
- package/dist/search/scanning.js.map +0 -1
package/dist/harness/skills.js
CHANGED
|
@@ -16,11 +16,11 @@ export function formatSkillInvocation(skill, additionalInstructions) {
|
|
|
16
16
|
* frontmatter, honors ignore files, and returns diagnostics for invalid declared skill files. Missing input
|
|
17
17
|
* directories are skipped.
|
|
18
18
|
*/
|
|
19
|
-
export async function loadSkills(env, dirs) {
|
|
19
|
+
export async function loadSkills(env, dirs, context) {
|
|
20
20
|
const skills = [];
|
|
21
21
|
const diagnostics = [];
|
|
22
22
|
for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
|
|
23
|
-
const rootInfoResult = await env.fileInfo(dir);
|
|
23
|
+
const rootInfoResult = await env.fileInfo(dir, context);
|
|
24
24
|
if (!rootInfoResult.ok) {
|
|
25
25
|
if (rootInfoResult.error.code !== "not_found") {
|
|
26
26
|
diagnostics.push({
|
|
@@ -33,9 +33,9 @@ export async function loadSkills(env, dirs) {
|
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
35
|
const rootInfo = rootInfoResult.value;
|
|
36
|
-
if ((await resolveKind(env, rootInfo, diagnostics)) !== "directory")
|
|
36
|
+
if ((await resolveKind(env, rootInfo, diagnostics, context)) !== "directory")
|
|
37
37
|
continue;
|
|
38
|
-
const result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path);
|
|
38
|
+
const result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path, context);
|
|
39
39
|
skills.push(...result.skills);
|
|
40
40
|
diagnostics.push(...result.diagnostics);
|
|
41
41
|
}
|
|
@@ -47,23 +47,26 @@ export async function loadSkills(env, dirs) {
|
|
|
47
47
|
* Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not
|
|
48
48
|
* interpret source values; applications define their own provenance shape.
|
|
49
49
|
*/
|
|
50
|
-
export async function loadSourcedSkills(env, inputs, mapSkill) {
|
|
50
|
+
export async function loadSourcedSkills(env, inputs, mapSkill, context) {
|
|
51
51
|
const skills = [];
|
|
52
52
|
const diagnostics = [];
|
|
53
53
|
for (const input of inputs) {
|
|
54
|
-
const result = await loadSkills(env, input.path);
|
|
54
|
+
const result = await loadSkills(env, input.path, context);
|
|
55
55
|
for (const skill of result.skills) {
|
|
56
|
-
skills.push({
|
|
56
|
+
skills.push({
|
|
57
|
+
skill: mapSkill ? mapSkill(skill, input.source, context) : skill,
|
|
58
|
+
source: input.source,
|
|
59
|
+
});
|
|
57
60
|
}
|
|
58
61
|
for (const diagnostic of result.diagnostics)
|
|
59
62
|
diagnostics.push({ ...diagnostic, source: input.source });
|
|
60
63
|
}
|
|
61
64
|
return { skills, diagnostics };
|
|
62
65
|
}
|
|
63
|
-
async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatcher, rootDir) {
|
|
66
|
+
async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatcher, rootDir, context) {
|
|
64
67
|
const skills = [];
|
|
65
68
|
const diagnostics = [];
|
|
66
|
-
const dirInfoResult = await env.fileInfo(dir);
|
|
69
|
+
const dirInfoResult = await env.fileInfo(dir, context);
|
|
67
70
|
if (!dirInfoResult.ok) {
|
|
68
71
|
if (dirInfoResult.error.code !== "not_found") {
|
|
69
72
|
diagnostics.push({
|
|
@@ -76,10 +79,10 @@ async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatch
|
|
|
76
79
|
return { skills, diagnostics };
|
|
77
80
|
}
|
|
78
81
|
const dirInfo = dirInfoResult.value;
|
|
79
|
-
if ((await resolveKind(env, dirInfo, diagnostics)) !== "directory")
|
|
82
|
+
if ((await resolveKind(env, dirInfo, diagnostics, context)) !== "directory")
|
|
80
83
|
return { skills, diagnostics };
|
|
81
|
-
await addIgnoreRules(env, ignoreMatcher, dir, rootDir, diagnostics);
|
|
82
|
-
const entriesResult = await env.listDir(dir);
|
|
84
|
+
await addIgnoreRules(env, ignoreMatcher, dir, rootDir, diagnostics, context);
|
|
85
|
+
const entriesResult = await env.listDir(dir, context);
|
|
83
86
|
if (!entriesResult.ok) {
|
|
84
87
|
diagnostics.push({ type: "warning", code: "list_failed", message: entriesResult.error.message, path: dir });
|
|
85
88
|
return { skills, diagnostics };
|
|
@@ -89,13 +92,13 @@ async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatch
|
|
|
89
92
|
if (entry.name !== "SKILL.md")
|
|
90
93
|
continue;
|
|
91
94
|
const fullPath = entry.path;
|
|
92
|
-
const kind = await resolveKind(env, entry, diagnostics);
|
|
95
|
+
const kind = await resolveKind(env, entry, diagnostics, context);
|
|
93
96
|
if (kind !== "file")
|
|
94
97
|
continue;
|
|
95
98
|
const relPath = relativeEnvPath(rootDir, fullPath);
|
|
96
99
|
if (ignoreMatcher.ignores(relPath))
|
|
97
100
|
continue;
|
|
98
|
-
const result = await loadSkillFromFile(env, fullPath, dirInfo.name);
|
|
101
|
+
const result = await loadSkillFromFile(env, fullPath, dirInfo.name, context);
|
|
99
102
|
if (result.skill)
|
|
100
103
|
skills.push(result.skill);
|
|
101
104
|
diagnostics.push(...result.diagnostics);
|
|
@@ -105,7 +108,7 @@ async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatch
|
|
|
105
108
|
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
106
109
|
continue;
|
|
107
110
|
const fullPath = entry.path;
|
|
108
|
-
const kind = await resolveKind(env, entry, diagnostics);
|
|
111
|
+
const kind = await resolveKind(env, entry, diagnostics, context);
|
|
109
112
|
if (!kind)
|
|
110
113
|
continue;
|
|
111
114
|
const relPath = relativeEnvPath(rootDir, fullPath);
|
|
@@ -113,25 +116,25 @@ async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatch
|
|
|
113
116
|
if (ignoreMatcher.ignores(ignorePath))
|
|
114
117
|
continue;
|
|
115
118
|
if (kind === "directory") {
|
|
116
|
-
const result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir);
|
|
119
|
+
const result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir, context);
|
|
117
120
|
skills.push(...result.skills);
|
|
118
121
|
diagnostics.push(...result.diagnostics);
|
|
119
122
|
continue;
|
|
120
123
|
}
|
|
121
124
|
if (kind !== "file" || !includeRootFiles || !entry.name.endsWith(".md"))
|
|
122
125
|
continue;
|
|
123
|
-
const result = await loadSkillFromFile(env, fullPath, dirInfo.name);
|
|
126
|
+
const result = await loadSkillFromFile(env, fullPath, dirInfo.name, context);
|
|
124
127
|
if (result.skill)
|
|
125
128
|
skills.push(result.skill);
|
|
126
129
|
diagnostics.push(...result.diagnostics);
|
|
127
130
|
}
|
|
128
131
|
return { skills, diagnostics };
|
|
129
132
|
}
|
|
130
|
-
async function addIgnoreRules(env, ig, dir, rootDir, diagnostics) {
|
|
133
|
+
async function addIgnoreRules(env, ig, dir, rootDir, diagnostics, context) {
|
|
131
134
|
const relativeDir = relativeEnvPath(rootDir, dir);
|
|
132
135
|
const prefix = relativeDir ? `${relativeDir}/` : "";
|
|
133
136
|
for (const filename of IGNORE_FILE_NAMES) {
|
|
134
|
-
const ignorePathResult = await env.joinPath([dir, filename]);
|
|
137
|
+
const ignorePathResult = await env.joinPath([dir, filename], context);
|
|
135
138
|
if (!ignorePathResult.ok) {
|
|
136
139
|
diagnostics.push({
|
|
137
140
|
type: "warning",
|
|
@@ -142,7 +145,7 @@ async function addIgnoreRules(env, ig, dir, rootDir, diagnostics) {
|
|
|
142
145
|
continue;
|
|
143
146
|
}
|
|
144
147
|
const ignorePath = ignorePathResult.value;
|
|
145
|
-
const info = await env.fileInfo(ignorePath);
|
|
148
|
+
const info = await env.fileInfo(ignorePath, context);
|
|
146
149
|
if (!info.ok) {
|
|
147
150
|
if (info.error.code !== "not_found") {
|
|
148
151
|
diagnostics.push({
|
|
@@ -156,7 +159,7 @@ async function addIgnoreRules(env, ig, dir, rootDir, diagnostics) {
|
|
|
156
159
|
}
|
|
157
160
|
if (info.value.kind !== "file")
|
|
158
161
|
continue;
|
|
159
|
-
const content = await env.readTextFile(ignorePath);
|
|
162
|
+
const content = await env.readTextFile(ignorePath, context);
|
|
160
163
|
if (!content.ok) {
|
|
161
164
|
diagnostics.push({ type: "warning", code: "read_failed", message: content.error.message, path: ignorePath });
|
|
162
165
|
continue;
|
|
@@ -189,13 +192,13 @@ function prefixIgnorePattern(line, prefix) {
|
|
|
189
192
|
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
190
193
|
return negated ? `!${prefixed}` : prefixed;
|
|
191
194
|
}
|
|
192
|
-
async function loadSkillFromFile(env, filePath, parentDirName) {
|
|
195
|
+
async function loadSkillFromFile(env, filePath, parentDirName, context) {
|
|
193
196
|
const diagnostics = [];
|
|
194
197
|
const isDeclaredSkill = filePath
|
|
195
198
|
.replace(/[\\/]+$/, "")
|
|
196
199
|
.split(/[\\/]/)
|
|
197
200
|
.pop() === "SKILL.md";
|
|
198
|
-
const rawContent = await env.readTextFile(filePath);
|
|
201
|
+
const rawContent = await env.readTextFile(filePath, context);
|
|
199
202
|
if (!rawContent.ok) {
|
|
200
203
|
diagnostics.push({ type: "warning", code: "read_failed", message: rawContent.error.message, path: filePath });
|
|
201
204
|
return { skill: null, diagnostics };
|
|
@@ -275,10 +278,10 @@ function parseFrontmatter(content) {
|
|
|
275
278
|
return { ok: false, error: toError(error) };
|
|
276
279
|
}
|
|
277
280
|
}
|
|
278
|
-
async function resolveKind(env, info, diagnostics) {
|
|
281
|
+
async function resolveKind(env, info, diagnostics, context) {
|
|
279
282
|
if (info.kind === "file" || info.kind === "directory")
|
|
280
283
|
return info.kind;
|
|
281
|
-
const canonicalPath = await env.canonicalPath(info.path);
|
|
284
|
+
const canonicalPath = await env.canonicalPath(info.path, context);
|
|
282
285
|
if (!canonicalPath.ok) {
|
|
283
286
|
if (canonicalPath.error.code !== "not_found") {
|
|
284
287
|
diagnostics.push({
|
|
@@ -290,7 +293,7 @@ async function resolveKind(env, info, diagnostics) {
|
|
|
290
293
|
}
|
|
291
294
|
return undefined;
|
|
292
295
|
}
|
|
293
|
-
const target = await env.fileInfo(canonicalPath.value);
|
|
296
|
+
const target = await env.fileInfo(canonicalPath.value, context);
|
|
294
297
|
if (!target.ok) {
|
|
295
298
|
if (target.error.code !== "not_found") {
|
|
296
299
|
diagnostics.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/harness/skills.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAA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,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3F,IAAI,cAAc,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,OAAO,cAAc,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AAAA,CACvE;AAED,SAAS,eAAe,CAAC,IAAY,EAAE,IAAY,EAAU;IAC5D,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpE,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,cAAc,KAAK,cAAc;QAAE,OAAO,EAAE,CAAC;IACjD,OAAO,cAAc,CAAC,UAAU,CAAC,GAAG,cAAc,GAAG,CAAC;QACrD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QACjD,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAAA,CACtC","sourcesContent":["import ignore from \"ignore\";\nimport { parse } from \"yaml\";\nimport { type ExecutionEnv, type FileInfo, type Result, type Skill, toError } from \"./types.ts\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nexport type SkillDiagnosticCode =\n\t| \"file_info_failed\"\n\t| \"list_failed\"\n\t| \"read_failed\"\n\t| \"parse_failed\"\n\t| \"invalid_metadata\";\n\n/** Warning produced while loading skills. */\nexport interface SkillDiagnostic {\n\t/** Diagnostic severity. Currently only warnings are emitted. */\n\ttype: \"warning\";\n\t/** Stable diagnostic code. */\n\tcode: SkillDiagnosticCode;\n\t/** Human-readable diagnostic message. */\n\tmessage: string;\n\t/** Path associated with the diagnostic. */\n\tpath: string;\n}\n\ninterface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\n/** Format a skill invocation prompt, optionally appending additional user instructions. */\nexport function formatSkillInvocation(skill: Skill, additionalInstructions?: string): string {\n\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${dirnameEnvPath(skill.filePath)}.\\n\\n${skill.content}\\n</skill>`;\n\treturn additionalInstructions ? `${skillBlock}\\n\\n${additionalInstructions}` : skillBlock;\n}\n\n/**\n * Load skills from one or more directories.\n *\n * Traverses directories recursively, loads `SKILL.md` files, loads direct root `.md` files with skill\n * frontmatter, honors ignore files, and returns diagnostics for invalid declared skill files. Missing input\n * directories are skipped.\n */\nexport async function loadSkills(\n\tenv: ExecutionEnv,\n\tdirs: string | string[],\n): Promise<{ skills: Skill[]; diagnostics: SkillDiagnostic[] }> {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: SkillDiagnostic[] = [];\n\tfor (const dir of Array.isArray(dirs) ? dirs : [dirs]) {\n\t\tconst rootInfoResult = await env.fileInfo(dir);\n\t\tif (!rootInfoResult.ok) {\n\t\t\tif (rootInfoResult.error.code !== \"not_found\") {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\t\tmessage: rootInfoResult.error.message,\n\t\t\t\t\tpath: dir,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst rootInfo = rootInfoResult.value;\n\t\tif ((await resolveKind(env, rootInfo, diagnostics)) !== \"directory\") continue;\n\t\tconst result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path);\n\t\tskills.push(...result.skills);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\treturn { skills, diagnostics };\n}\n\n/**\n * Load skills from source-tagged directories.\n *\n * Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not\n * interpret source values; applications define their own provenance shape.\n */\nexport async function loadSourcedSkills<TSource, TSkill extends Skill = Skill>(\n\tenv: ExecutionEnv,\n\tinputs: Array<{ path: string; source: TSource }>,\n\tmapSkill?: (skill: Skill, source: TSource) => TSkill,\n): Promise<{\n\tskills: Array<{ skill: TSkill; source: TSource }>;\n\tdiagnostics: Array<SkillDiagnostic & { source: TSource }>;\n}> {\n\tconst skills: Array<{ skill: TSkill; source: TSource }> = [];\n\tconst diagnostics: Array<SkillDiagnostic & { source: TSource }> = [];\n\tfor (const input of inputs) {\n\t\tconst result = await loadSkills(env, input.path);\n\t\tfor (const skill of result.skills) {\n\t\t\tskills.push({ skill: mapSkill ? mapSkill(skill, input.source) : (skill as TSkill), source: input.source });\n\t\t}\n\t\tfor (const diagnostic of result.diagnostics) diagnostics.push({ ...diagnostic, source: input.source });\n\t}\n\treturn { skills, diagnostics };\n}\n\nasync function loadSkillsFromDirInternal(\n\tenv: ExecutionEnv,\n\tdir: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher: IgnoreMatcher,\n\trootDir: string,\n): Promise<{ skills: Skill[]; diagnostics: SkillDiagnostic[] }> {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: SkillDiagnostic[] = [];\n\n\tconst dirInfoResult = await env.fileInfo(dir);\n\tif (!dirInfoResult.ok) {\n\t\tif (dirInfoResult.error.code !== \"not_found\") {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: dirInfoResult.error.message,\n\t\t\t\tpath: dir,\n\t\t\t});\n\t\t}\n\t\treturn { skills, diagnostics };\n\t}\n\tconst dirInfo = dirInfoResult.value;\n\tif ((await resolveKind(env, dirInfo, diagnostics)) !== \"directory\") return { skills, diagnostics };\n\n\tawait addIgnoreRules(env, ignoreMatcher, dir, rootDir, diagnostics);\n\n\tconst entriesResult = await env.listDir(dir);\n\tif (!entriesResult.ok) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"list_failed\", message: entriesResult.error.message, path: dir });\n\t\treturn { skills, diagnostics };\n\t}\n\tconst entries = entriesResult.value;\n\n\tfor (const entry of entries) {\n\t\tif (entry.name !== \"SKILL.md\") continue;\n\t\tconst fullPath = entry.path;\n\t\tconst kind = await resolveKind(env, entry, diagnostics);\n\t\tif (kind !== \"file\") continue;\n\t\tconst relPath = relativeEnvPath(rootDir, fullPath);\n\t\tif (ignoreMatcher.ignores(relPath)) continue;\n\n\t\tconst result = await loadSkillFromFile(env, fullPath, dirInfo.name);\n\t\tif (result.skill) skills.push(result.skill);\n\t\tdiagnostics.push(...result.diagnostics);\n\t\treturn { skills, diagnostics };\n\t}\n\n\tfor (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\tconst fullPath = entry.path;\n\t\tconst kind = await resolveKind(env, entry, diagnostics);\n\t\tif (!kind) continue;\n\n\t\tconst relPath = relativeEnvPath(rootDir, fullPath);\n\t\tconst ignorePath = kind === \"directory\" ? `${relPath}/` : relPath;\n\t\tif (ignoreMatcher.ignores(ignorePath)) continue;\n\n\t\tif (kind === \"directory\") {\n\t\t\tconst result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir);\n\t\t\tskills.push(...result.skills);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (kind !== \"file\" || !includeRootFiles || !entry.name.endsWith(\".md\")) continue;\n\t\tconst result = await loadSkillFromFile(env, fullPath, dirInfo.name);\n\t\tif (result.skill) skills.push(result.skill);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\n\treturn { skills, diagnostics };\n}\n\nasync function addIgnoreRules(\n\tenv: ExecutionEnv,\n\tig: IgnoreMatcher,\n\tdir: string,\n\trootDir: string,\n\tdiagnostics: SkillDiagnostic[],\n): Promise<void> {\n\tconst relativeDir = relativeEnvPath(rootDir, dir);\n\tconst prefix = relativeDir ? `${relativeDir}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePathResult = await env.joinPath([dir, filename]);\n\t\tif (!ignorePathResult.ok) {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: ignorePathResult.error.message,\n\t\t\t\tpath: dir,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst ignorePath = ignorePathResult.value;\n\t\tconst info = await env.fileInfo(ignorePath);\n\t\tif (!info.ok) {\n\t\t\tif (info.error.code !== \"not_found\") {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\t\tmessage: info.error.message,\n\t\t\t\t\tpath: ignorePath,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (info.value.kind !== \"file\") continue;\n\t\tconst content = await env.readTextFile(ignorePath);\n\t\tif (!content.ok) {\n\t\t\tdiagnostics.push({ type: \"warning\", code: \"read_failed\", message: content.error.message, path: ignorePath });\n\t\t\tcontinue;\n\t\t}\n\t\tconst patterns = content.value\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t.filter((line): line is string => Boolean(line));\n\t\tif (patterns.length > 0) ig.add(patterns);\n\t}\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nasync function loadSkillFromFile(\n\tenv: ExecutionEnv,\n\tfilePath: string,\n\tparentDirName: string,\n): Promise<{ skill: Skill | null; diagnostics: SkillDiagnostic[] }> {\n\tconst diagnostics: SkillDiagnostic[] = [];\n\tconst isDeclaredSkill =\n\t\tfilePath\n\t\t\t.replace(/[\\\\/]+$/, \"\")\n\t\t\t.split(/[\\\\/]/)\n\t\t\t.pop() === \"SKILL.md\";\n\tconst rawContent = await env.readTextFile(filePath);\n\tif (!rawContent.ok) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"read_failed\", message: rawContent.error.message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tconst parsed = parseFrontmatter<SkillFrontmatter>(rawContent.value);\n\tif (!parsed.ok) {\n\t\tif (isDeclaredSkill) {\n\t\t\tdiagnostics.push({ type: \"warning\", code: \"parse_failed\", message: parsed.error.message, path: filePath });\n\t\t}\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tconst { frontmatter, body } = parsed.value;\n\tconst description = typeof frontmatter.description === \"string\" ? frontmatter.description : undefined;\n\tif (!isDeclaredSkill && (!description || description.trim() === \"\")) {\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tfor (const error of validateDescription(description)) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"invalid_metadata\", message: error, path: filePath });\n\t}\n\n\tconst frontmatterName = typeof frontmatter.name === \"string\" ? frontmatter.name : undefined;\n\tconst name = frontmatterName || parentDirName;\n\tfor (const error of validateName(name, parentDirName)) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"invalid_metadata\", message: error, path: filePath });\n\t}\n\n\tif (!description || description.trim() === \"\") {\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\treturn {\n\t\tskill: {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tcontent: body,\n\t\t\tfilePath,\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t},\n\t\tdiagnostics,\n\t};\n}\n\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\tif (name !== parentDirName) errors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\tif (name.length > MAX_NAME_LENGTH) errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) errors.push(\"name must not start or end with a hyphen\");\n\tif (name.includes(\"--\")) errors.push(\"name must not contain consecutive hyphens\");\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\treturn errors;\n}\n\nfunction parseFrontmatter<T extends Record<string, unknown>>(\n\tcontent: string,\n): Result<{ frontmatter: T; body: string }, Error> {\n\ttry {\n\t\tconst normalized = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\t\tif (!normalized.startsWith(\"---\")) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\t\tif (endIndex === -1) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst yamlString = normalized.slice(4, endIndex);\n\t\tconst body = normalized.slice(endIndex + 4).trim();\n\t\treturn { ok: true, value: { frontmatter: (parse(yamlString) ?? {}) as T, body } };\n\t} catch (error) {\n\t\treturn { ok: false, error: toError(error) };\n\t}\n}\n\nasync function resolveKind(\n\tenv: ExecutionEnv,\n\tinfo: FileInfo,\n\tdiagnostics: SkillDiagnostic[],\n): Promise<\"file\" | \"directory\" | undefined> {\n\tif (info.kind === \"file\" || info.kind === \"directory\") return info.kind;\n\tconst canonicalPath = await env.canonicalPath(info.path);\n\tif (!canonicalPath.ok) {\n\t\tif (canonicalPath.error.code !== \"not_found\") {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: canonicalPath.error.message,\n\t\t\t\tpath: info.path,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\tconst target = await env.fileInfo(canonicalPath.value);\n\tif (!target.ok) {\n\t\tif (target.error.code !== \"not_found\") {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: target.error.message,\n\t\t\t\tpath: info.path,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\treturn target.value.kind === \"file\" || target.value.kind === \"directory\" ? target.value.kind : undefined;\n}\n\nfunction dirnameEnvPath(path: string): string {\n\tconst normalized = path.replace(/[\\\\/]+$/, \"\");\n\tconst separatorIndex = Math.max(normalized.lastIndexOf(\"/\"), normalized.lastIndexOf(\"\\\\\"));\n\tif (separatorIndex === 2 && normalized[1] === \":\") return normalized.slice(0, 3);\n\treturn separatorIndex <= 0 ? \"/\" : normalized.slice(0, separatorIndex);\n}\n\nfunction relativeEnvPath(root: string, path: string): string {\n\tconst normalizedRoot = root.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n\tconst normalizedPath = path.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n\tif (normalizedPath === normalizedRoot) return \"\";\n\treturn normalizedPath.startsWith(`${normalizedRoot}/`)\n\t\t? normalizedPath.slice(normalizedRoot.length + 1)\n\t\t: normalizedPath.replace(/^\\/+/, \"\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/harness/skills.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,OAAO,EAA6D,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhG,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AA8BjE,2FAA2F;AAC3F,MAAM,UAAU,qBAAqB,CAAC,KAAY,EAAE,sBAA+B,EAAU;IAC5F,MAAM,UAAU,GAAG,gBAAgB,KAAK,CAAC,IAAI,eAAe,KAAK,CAAC,QAAQ,kCAAkC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,KAAK,CAAC,OAAO,YAAY,CAAC;IAC5K,OAAO,sBAAsB,CAAC,CAAC,CAAC,GAAG,UAAU,OAAO,sBAAsB,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AAAA,CAC1F;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC/B,GAAiB,EACjB,IAAuB,EACvB,OAAgB,EAC+C;IAC/D,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAsB,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,C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AAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpE,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpE,IAAI,cAAc,KAAK,cAAc;QAAE,OAAO,EAAE,CAAC;IACjD,OAAO,cAAc,CAAC,UAAU,CAAC,GAAG,cAAc,GAAG,CAAC;QACrD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QACjD,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAAA,CACtC","sourcesContent":["import ignore from \"ignore\";\nimport { parse } from \"yaml\";\nimport type { Context } from \"./context.ts\";\nimport { type ExecutionEnv, type FileInfo, type Result, type Skill, toError } from \"./types.ts\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nexport type SkillDiagnosticCode =\n\t| \"file_info_failed\"\n\t| \"list_failed\"\n\t| \"read_failed\"\n\t| \"parse_failed\"\n\t| \"invalid_metadata\";\n\n/** Warning produced while loading skills. */\nexport interface SkillDiagnostic {\n\t/** Diagnostic severity. Currently only warnings are emitted. */\n\ttype: \"warning\";\n\t/** Stable diagnostic code. */\n\tcode: SkillDiagnosticCode;\n\t/** Human-readable diagnostic message. */\n\tmessage: string;\n\t/** Path associated with the diagnostic. */\n\tpath: string;\n}\n\ninterface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\n/** Format a skill invocation prompt, optionally appending additional user instructions. */\nexport function formatSkillInvocation(skill: Skill, additionalInstructions?: string): string {\n\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${dirnameEnvPath(skill.filePath)}.\\n\\n${skill.content}\\n</skill>`;\n\treturn additionalInstructions ? `${skillBlock}\\n\\n${additionalInstructions}` : skillBlock;\n}\n\n/**\n * Load skills from one or more directories.\n *\n * Traverses directories recursively, loads `SKILL.md` files, loads direct root `.md` files with skill\n * frontmatter, honors ignore files, and returns diagnostics for invalid declared skill files. Missing input\n * directories are skipped.\n */\nexport async function loadSkills(\n\tenv: ExecutionEnv,\n\tdirs: string | string[],\n\tcontext: Context,\n): Promise<{ skills: Skill[]; diagnostics: SkillDiagnostic[] }> {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: SkillDiagnostic[] = [];\n\tfor (const dir of Array.isArray(dirs) ? dirs : [dirs]) {\n\t\tconst rootInfoResult = await env.fileInfo(dir, context);\n\t\tif (!rootInfoResult.ok) {\n\t\t\tif (rootInfoResult.error.code !== \"not_found\") {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\t\tmessage: rootInfoResult.error.message,\n\t\t\t\t\tpath: dir,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst rootInfo = rootInfoResult.value;\n\t\tif ((await resolveKind(env, rootInfo, diagnostics, context)) !== \"directory\") continue;\n\t\tconst result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path, context);\n\t\tskills.push(...result.skills);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\treturn { skills, diagnostics };\n}\n\n/**\n * Load skills from source-tagged directories.\n *\n * Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not\n * interpret source values; applications define their own provenance shape.\n */\nexport async function loadSourcedSkills<TSource, TSkill extends Skill = Skill>(\n\tenv: ExecutionEnv,\n\tinputs: Array<{ path: string; source: TSource }>,\n\tmapSkill: ((skill: Skill, source: TSource, context: Context) => TSkill) | undefined,\n\tcontext: Context,\n): Promise<{\n\tskills: Array<{ skill: TSkill; source: TSource }>;\n\tdiagnostics: Array<SkillDiagnostic & { source: TSource }>;\n}> {\n\tconst skills: Array<{ skill: TSkill; source: TSource }> = [];\n\tconst diagnostics: Array<SkillDiagnostic & { source: TSource }> = [];\n\tfor (const input of inputs) {\n\t\tconst result = await loadSkills(env, input.path, context);\n\t\tfor (const skill of result.skills) {\n\t\t\tskills.push({\n\t\t\t\tskill: mapSkill ? mapSkill(skill, input.source, context) : (skill as TSkill),\n\t\t\t\tsource: input.source,\n\t\t\t});\n\t\t}\n\t\tfor (const diagnostic of result.diagnostics) diagnostics.push({ ...diagnostic, source: input.source });\n\t}\n\treturn { skills, diagnostics };\n}\n\nasync function loadSkillsFromDirInternal(\n\tenv: ExecutionEnv,\n\tdir: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher: IgnoreMatcher,\n\trootDir: string,\n\tcontext: Context,\n): Promise<{ skills: Skill[]; diagnostics: SkillDiagnostic[] }> {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: SkillDiagnostic[] = [];\n\n\tconst dirInfoResult = await env.fileInfo(dir, context);\n\tif (!dirInfoResult.ok) {\n\t\tif (dirInfoResult.error.code !== \"not_found\") {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: dirInfoResult.error.message,\n\t\t\t\tpath: dir,\n\t\t\t});\n\t\t}\n\t\treturn { skills, diagnostics };\n\t}\n\tconst dirInfo = dirInfoResult.value;\n\tif ((await resolveKind(env, dirInfo, diagnostics, context)) !== \"directory\") return { skills, diagnostics };\n\n\tawait addIgnoreRules(env, ignoreMatcher, dir, rootDir, diagnostics, context);\n\n\tconst entriesResult = await env.listDir(dir, context);\n\tif (!entriesResult.ok) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"list_failed\", message: entriesResult.error.message, path: dir });\n\t\treturn { skills, diagnostics };\n\t}\n\tconst entries = entriesResult.value;\n\n\tfor (const entry of entries) {\n\t\tif (entry.name !== \"SKILL.md\") continue;\n\t\tconst fullPath = entry.path;\n\t\tconst kind = await resolveKind(env, entry, diagnostics, context);\n\t\tif (kind !== \"file\") continue;\n\t\tconst relPath = relativeEnvPath(rootDir, fullPath);\n\t\tif (ignoreMatcher.ignores(relPath)) continue;\n\n\t\tconst result = await loadSkillFromFile(env, fullPath, dirInfo.name, context);\n\t\tif (result.skill) skills.push(result.skill);\n\t\tdiagnostics.push(...result.diagnostics);\n\t\treturn { skills, diagnostics };\n\t}\n\n\tfor (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\tconst fullPath = entry.path;\n\t\tconst kind = await resolveKind(env, entry, diagnostics, context);\n\t\tif (!kind) continue;\n\n\t\tconst relPath = relativeEnvPath(rootDir, fullPath);\n\t\tconst ignorePath = kind === \"directory\" ? `${relPath}/` : relPath;\n\t\tif (ignoreMatcher.ignores(ignorePath)) continue;\n\n\t\tif (kind === \"directory\") {\n\t\t\tconst result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir, context);\n\t\t\tskills.push(...result.skills);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (kind !== \"file\" || !includeRootFiles || !entry.name.endsWith(\".md\")) continue;\n\t\tconst result = await loadSkillFromFile(env, fullPath, dirInfo.name, context);\n\t\tif (result.skill) skills.push(result.skill);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\n\treturn { skills, diagnostics };\n}\n\nasync function addIgnoreRules(\n\tenv: ExecutionEnv,\n\tig: IgnoreMatcher,\n\tdir: string,\n\trootDir: string,\n\tdiagnostics: SkillDiagnostic[],\n\tcontext: Context,\n): Promise<void> {\n\tconst relativeDir = relativeEnvPath(rootDir, dir);\n\tconst prefix = relativeDir ? `${relativeDir}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePathResult = await env.joinPath([dir, filename], context);\n\t\tif (!ignorePathResult.ok) {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: ignorePathResult.error.message,\n\t\t\t\tpath: dir,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst ignorePath = ignorePathResult.value;\n\t\tconst info = await env.fileInfo(ignorePath, context);\n\t\tif (!info.ok) {\n\t\t\tif (info.error.code !== \"not_found\") {\n\t\t\t\tdiagnostics.push({\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\t\tmessage: info.error.message,\n\t\t\t\t\tpath: ignorePath,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (info.value.kind !== \"file\") continue;\n\t\tconst content = await env.readTextFile(ignorePath, context);\n\t\tif (!content.ok) {\n\t\t\tdiagnostics.push({ type: \"warning\", code: \"read_failed\", message: content.error.message, path: ignorePath });\n\t\t\tcontinue;\n\t\t}\n\t\tconst patterns = content.value\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t.filter((line): line is string => Boolean(line));\n\t\tif (patterns.length > 0) ig.add(patterns);\n\t}\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nasync function loadSkillFromFile(\n\tenv: ExecutionEnv,\n\tfilePath: string,\n\tparentDirName: string,\n\tcontext: Context,\n): Promise<{ skill: Skill | null; diagnostics: SkillDiagnostic[] }> {\n\tconst diagnostics: SkillDiagnostic[] = [];\n\tconst isDeclaredSkill =\n\t\tfilePath\n\t\t\t.replace(/[\\\\/]+$/, \"\")\n\t\t\t.split(/[\\\\/]/)\n\t\t\t.pop() === \"SKILL.md\";\n\tconst rawContent = await env.readTextFile(filePath, context);\n\tif (!rawContent.ok) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"read_failed\", message: rawContent.error.message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tconst parsed = parseFrontmatter<SkillFrontmatter>(rawContent.value);\n\tif (!parsed.ok) {\n\t\tif (isDeclaredSkill) {\n\t\t\tdiagnostics.push({ type: \"warning\", code: \"parse_failed\", message: parsed.error.message, path: filePath });\n\t\t}\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tconst { frontmatter, body } = parsed.value;\n\tconst description = typeof frontmatter.description === \"string\" ? frontmatter.description : undefined;\n\tif (!isDeclaredSkill && (!description || description.trim() === \"\")) {\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tfor (const error of validateDescription(description)) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"invalid_metadata\", message: error, path: filePath });\n\t}\n\n\tconst frontmatterName = typeof frontmatter.name === \"string\" ? frontmatter.name : undefined;\n\tconst name = frontmatterName || parentDirName;\n\tfor (const error of validateName(name, parentDirName)) {\n\t\tdiagnostics.push({ type: \"warning\", code: \"invalid_metadata\", message: error, path: filePath });\n\t}\n\n\tif (!description || description.trim() === \"\") {\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\treturn {\n\t\tskill: {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tcontent: body,\n\t\t\tfilePath,\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t},\n\t\tdiagnostics,\n\t};\n}\n\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\tif (name !== parentDirName) errors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\tif (name.length > MAX_NAME_LENGTH) errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) errors.push(\"name must not start or end with a hyphen\");\n\tif (name.includes(\"--\")) errors.push(\"name must not contain consecutive hyphens\");\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\treturn errors;\n}\n\nfunction parseFrontmatter<T extends Record<string, unknown>>(\n\tcontent: string,\n): Result<{ frontmatter: T; body: string }, Error> {\n\ttry {\n\t\tconst normalized = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\t\tif (!normalized.startsWith(\"---\")) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\t\tif (endIndex === -1) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst yamlString = normalized.slice(4, endIndex);\n\t\tconst body = normalized.slice(endIndex + 4).trim();\n\t\treturn { ok: true, value: { frontmatter: (parse(yamlString) ?? {}) as T, body } };\n\t} catch (error) {\n\t\treturn { ok: false, error: toError(error) };\n\t}\n}\n\nasync function resolveKind(\n\tenv: ExecutionEnv,\n\tinfo: FileInfo,\n\tdiagnostics: SkillDiagnostic[],\n\tcontext: Context,\n): Promise<\"file\" | \"directory\" | undefined> {\n\tif (info.kind === \"file\" || info.kind === \"directory\") return info.kind;\n\tconst canonicalPath = await env.canonicalPath(info.path, context);\n\tif (!canonicalPath.ok) {\n\t\tif (canonicalPath.error.code !== \"not_found\") {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: canonicalPath.error.message,\n\t\t\t\tpath: info.path,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\tconst target = await env.fileInfo(canonicalPath.value, context);\n\tif (!target.ok) {\n\t\tif (target.error.code !== \"not_found\") {\n\t\t\tdiagnostics.push({\n\t\t\t\ttype: \"warning\",\n\t\t\t\tcode: \"file_info_failed\",\n\t\t\t\tmessage: target.error.message,\n\t\t\t\tpath: info.path,\n\t\t\t});\n\t\t}\n\t\treturn undefined;\n\t}\n\treturn target.value.kind === \"file\" || target.value.kind === \"directory\" ? target.value.kind : undefined;\n}\n\nfunction dirnameEnvPath(path: string): string {\n\tconst normalized = path.replace(/[\\\\/]+$/, \"\");\n\tconst separatorIndex = Math.max(normalized.lastIndexOf(\"/\"), normalized.lastIndexOf(\"\\\\\"));\n\tif (separatorIndex === 2 && normalized[1] === \":\") return normalized.slice(0, 3);\n\treturn separatorIndex <= 0 ? \"/\" : normalized.slice(0, separatorIndex);\n}\n\nfunction relativeEnvPath(root: string, path: string): string {\n\tconst normalizedRoot = root.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n\tconst normalizedPath = path.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n\tif (normalizedPath === normalizedRoot) return \"\";\n\treturn normalizedPath.startsWith(`${normalizedRoot}/`)\n\t\t? normalizedPath.slice(normalizedRoot.length + 1)\n\t\t: normalizedPath.replace(/^\\/+/, \"\");\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ExactTelemetryAttributes, SchemaTelemetrySpan,
|
|
1
|
+
import type { ExactTelemetryAttributes, SchemaTelemetrySpan, TelemetrySchemaSpanEndAttributes, TelemetrySchemaSpanEventAttributes, TelemetrySchemaSpanEventName, TelemetrySchemaSpanName, TelemetrySchemaSpanStartAttributes, TelemetrySchemaSpanUnion } from "@earendil-works/pi-telemetry";
|
|
2
|
+
import { type Context } from "./context.ts";
|
|
2
3
|
export type { AttributeValue, ExactTelemetryAttributes, SchemaTelemetrySpan, SpanAttributes, SpanOptions, SpanStatus, TelemetryAttributeDefinition, TelemetryAttributeMetadata, TelemetryAttributeType, TelemetryContext, TelemetryEventAttributeDefinition, TelemetryEventDefinition, TelemetryParentDefinition, TelemetrySchemaDefinition, TelemetrySchemaSpanEndAttributes, TelemetrySchemaSpanEventAttributes, TelemetrySchemaSpanEventName, TelemetrySchemaSpanName, TelemetrySchemaSpanStartAttributes, TelemetrySchemaSpanUnion, TelemetrySpan, TelemetrySpanDefinition, TelemetryStartAttributeDefinition, TypedSpanStarter, } from "@earendil-works/pi-telemetry";
|
|
3
4
|
export declare const AI_TELEMETRY_SCHEMA: {
|
|
4
5
|
readonly version: 1;
|
|
@@ -117,7 +118,7 @@ export type AiSpanEventName<Name extends AiSpanName> = TelemetrySchemaSpanEventN
|
|
|
117
118
|
export type AiSpanEventAttributes<Name extends AiSpanName, EventName extends AiSpanEventName<Name>> = TelemetrySchemaSpanEventAttributes<typeof AI_TELEMETRY_SCHEMA, Name, EventName>;
|
|
118
119
|
export type AiTelemetrySpan<Name extends AiSpanName> = SchemaTelemetrySpan<typeof AI_TELEMETRY_SCHEMA, Name>;
|
|
119
120
|
export type AiSpan = TelemetrySchemaSpanUnion<typeof AI_TELEMETRY_SCHEMA>;
|
|
120
|
-
export declare function startAiSpan<Name extends AiSpanName, const Attributes extends AiSpanStartAttributes<Name>, Result>(
|
|
121
|
+
export declare function startAiSpan<Name extends AiSpanName, const Attributes extends AiSpanStartAttributes<Name>, Result>(name: Name, attributes: ExactTelemetryAttributes<AiSpanStartAttributes<Name>, Attributes>, callback: (span: AiTelemetrySpan<Name>, context: Context) => Result | Promise<Result>, context: Context): Promise<Result>;
|
|
121
122
|
export declare const HARNESS_TELEMETRY_SCHEMA: {
|
|
122
123
|
readonly version: 1;
|
|
123
124
|
readonly spans: {
|
|
@@ -317,7 +318,7 @@ export declare const HARNESS_TELEMETRY_SCHEMA: {
|
|
|
317
318
|
readonly "pi.checkpoint.kind": {
|
|
318
319
|
readonly type: "string";
|
|
319
320
|
readonly required: true;
|
|
320
|
-
readonly values: readonly ["normal", "
|
|
321
|
+
readonly values: readonly ["normal", "abort_reconcile"];
|
|
321
322
|
readonly description: "Checkpoint purpose";
|
|
322
323
|
};
|
|
323
324
|
};
|
|
@@ -488,13 +489,13 @@ export declare const HARNESS_TELEMETRY_SCHEMA: {
|
|
|
488
489
|
readonly "pi.hook.name": {
|
|
489
490
|
readonly type: "string";
|
|
490
491
|
readonly required: true;
|
|
491
|
-
readonly values: readonly ["before_run", "
|
|
492
|
+
readonly values: readonly ["before_run", "before_drive", "before_run_end", "transform_context", "before_request", "before_payload", "after_response", "before_tool", "after_tool", "before_compaction", "before_navigation"];
|
|
492
493
|
readonly description: "Hook name";
|
|
493
494
|
};
|
|
494
495
|
readonly "pi.hook.registration_id": {
|
|
495
496
|
readonly type: "string";
|
|
496
497
|
readonly required: false;
|
|
497
|
-
readonly description: "
|
|
498
|
+
readonly description: "Optional hook registration metadata";
|
|
498
499
|
};
|
|
499
500
|
};
|
|
500
501
|
readonly endAttributes: {
|
|
@@ -513,7 +514,7 @@ export declare const HARNESS_TELEMETRY_SCHEMA: {
|
|
|
513
514
|
readonly description: "One retry delay";
|
|
514
515
|
readonly parents: {
|
|
515
516
|
readonly kind: "spans";
|
|
516
|
-
readonly spans: readonly ["pi.harness.
|
|
517
|
+
readonly spans: readonly ["pi.harness.run", "pi.harness.compaction", "pi.harness.navigation", "pi.harness.turn", "pi.harness.checkpoint"];
|
|
517
518
|
};
|
|
518
519
|
readonly startAttributes: {
|
|
519
520
|
readonly "pi.operation.id": {
|
|
@@ -550,7 +551,7 @@ export declare const HARNESS_TELEMETRY_SCHEMA: {
|
|
|
550
551
|
readonly type: "string";
|
|
551
552
|
readonly required: true;
|
|
552
553
|
readonly cardinality: "low";
|
|
553
|
-
readonly values: readonly ["run_start", "run_resume", "run_suspend", "
|
|
554
|
+
readonly values: readonly ["run_start", "run_resume", "run_suspend", "operation_abort", "run_end", "fault", "handler_error", "turn_start", "turn_end", "retry_scheduled", "retry_start", "retry_end", "message_start", "message_update", "message_end", "tool_start", "tool_update", "tool_end", "entry_added", "queue_update", "value_update", "config_update", "compaction_start", "compaction_end", "navigation_start", "navigation_end", "lane_created", "usage"];
|
|
554
555
|
readonly description: "Delivered harness event type";
|
|
555
556
|
};
|
|
556
557
|
readonly "pi.lane.name": {
|
|
@@ -567,44 +568,54 @@ export declare const HARNESS_TELEMETRY_SCHEMA: {
|
|
|
567
568
|
};
|
|
568
569
|
};
|
|
569
570
|
readonly "pi.session.write": {
|
|
570
|
-
readonly description: "One committed session
|
|
571
|
+
readonly description: "One committed session transaction";
|
|
571
572
|
readonly parents: {
|
|
572
573
|
readonly kind: "any";
|
|
573
574
|
};
|
|
574
575
|
readonly startAttributes: {
|
|
575
|
-
readonly "pi.
|
|
576
|
+
readonly "pi.session.id": {
|
|
576
577
|
readonly type: "string";
|
|
577
578
|
readonly required: true;
|
|
578
579
|
readonly cardinality: "high";
|
|
579
|
-
readonly description: "
|
|
580
|
+
readonly description: "Session id";
|
|
580
581
|
};
|
|
581
|
-
readonly "pi.
|
|
582
|
+
readonly "pi.lane.name": {
|
|
582
583
|
readonly type: "string";
|
|
583
584
|
readonly required: false;
|
|
584
585
|
readonly cardinality: "high";
|
|
585
|
-
readonly description: "
|
|
586
|
+
readonly description: "Lane name when supplied by the caller";
|
|
586
587
|
};
|
|
587
|
-
readonly "pi.
|
|
588
|
+
readonly "pi.operation.id": {
|
|
588
589
|
readonly type: "string";
|
|
590
|
+
readonly required: false;
|
|
591
|
+
readonly cardinality: "high";
|
|
592
|
+
readonly description: "Durable operation id when supplied by the caller";
|
|
593
|
+
};
|
|
594
|
+
readonly "pi.session.item_count": {
|
|
595
|
+
readonly type: "number";
|
|
589
596
|
readonly required: true;
|
|
590
|
-
readonly
|
|
591
|
-
readonly description: "Session mutation kind";
|
|
597
|
+
readonly description: "Number of writes in the transaction";
|
|
592
598
|
};
|
|
593
|
-
readonly "pi.session.
|
|
594
|
-
readonly type: "string";
|
|
595
|
-
readonly required:
|
|
596
|
-
readonly
|
|
599
|
+
readonly "pi.session.item_kinds": {
|
|
600
|
+
readonly type: "string[]";
|
|
601
|
+
readonly required: true;
|
|
602
|
+
readonly elementValues: readonly ["entry", "usage", "value", "list"];
|
|
603
|
+
readonly description: "Distinct write kinds in the transaction";
|
|
597
604
|
};
|
|
598
605
|
};
|
|
599
606
|
readonly endAttributes: {
|
|
600
|
-
readonly "pi.session.
|
|
607
|
+
readonly "pi.session.first_seq": {
|
|
608
|
+
readonly type: "number";
|
|
609
|
+
readonly description: "First committed sequence in the transaction";
|
|
610
|
+
};
|
|
611
|
+
readonly "pi.session.last_seq": {
|
|
601
612
|
readonly type: "number";
|
|
602
|
-
readonly description: "
|
|
613
|
+
readonly description: "Last committed sequence in the transaction";
|
|
603
614
|
};
|
|
604
615
|
};
|
|
605
616
|
readonly status: {
|
|
606
617
|
readonly default: "ok";
|
|
607
|
-
readonly errorWhen: "Storage rejects the
|
|
618
|
+
readonly errorWhen: "Storage rejects the transaction";
|
|
608
619
|
};
|
|
609
620
|
};
|
|
610
621
|
};
|
|
@@ -917,7 +928,7 @@ export declare const AGENT_TELEMETRY_SCHEMAS: readonly [{
|
|
|
917
928
|
readonly "pi.checkpoint.kind": {
|
|
918
929
|
readonly type: "string";
|
|
919
930
|
readonly required: true;
|
|
920
|
-
readonly values: readonly ["normal", "
|
|
931
|
+
readonly values: readonly ["normal", "abort_reconcile"];
|
|
921
932
|
readonly description: "Checkpoint purpose";
|
|
922
933
|
};
|
|
923
934
|
};
|
|
@@ -1088,13 +1099,13 @@ export declare const AGENT_TELEMETRY_SCHEMAS: readonly [{
|
|
|
1088
1099
|
readonly "pi.hook.name": {
|
|
1089
1100
|
readonly type: "string";
|
|
1090
1101
|
readonly required: true;
|
|
1091
|
-
readonly values: readonly ["before_run", "
|
|
1102
|
+
readonly values: readonly ["before_run", "before_drive", "before_run_end", "transform_context", "before_request", "before_payload", "after_response", "before_tool", "after_tool", "before_compaction", "before_navigation"];
|
|
1092
1103
|
readonly description: "Hook name";
|
|
1093
1104
|
};
|
|
1094
1105
|
readonly "pi.hook.registration_id": {
|
|
1095
1106
|
readonly type: "string";
|
|
1096
1107
|
readonly required: false;
|
|
1097
|
-
readonly description: "
|
|
1108
|
+
readonly description: "Optional hook registration metadata";
|
|
1098
1109
|
};
|
|
1099
1110
|
};
|
|
1100
1111
|
readonly endAttributes: {
|
|
@@ -1113,7 +1124,7 @@ export declare const AGENT_TELEMETRY_SCHEMAS: readonly [{
|
|
|
1113
1124
|
readonly description: "One retry delay";
|
|
1114
1125
|
readonly parents: {
|
|
1115
1126
|
readonly kind: "spans";
|
|
1116
|
-
readonly spans: readonly ["pi.harness.
|
|
1127
|
+
readonly spans: readonly ["pi.harness.run", "pi.harness.compaction", "pi.harness.navigation", "pi.harness.turn", "pi.harness.checkpoint"];
|
|
1117
1128
|
};
|
|
1118
1129
|
readonly startAttributes: {
|
|
1119
1130
|
readonly "pi.operation.id": {
|
|
@@ -1150,7 +1161,7 @@ export declare const AGENT_TELEMETRY_SCHEMAS: readonly [{
|
|
|
1150
1161
|
readonly type: "string";
|
|
1151
1162
|
readonly required: true;
|
|
1152
1163
|
readonly cardinality: "low";
|
|
1153
|
-
readonly values: readonly ["run_start", "run_resume", "run_suspend", "
|
|
1164
|
+
readonly values: readonly ["run_start", "run_resume", "run_suspend", "operation_abort", "run_end", "fault", "handler_error", "turn_start", "turn_end", "retry_scheduled", "retry_start", "retry_end", "message_start", "message_update", "message_end", "tool_start", "tool_update", "tool_end", "entry_added", "queue_update", "value_update", "config_update", "compaction_start", "compaction_end", "navigation_start", "navigation_end", "lane_created", "usage"];
|
|
1154
1165
|
readonly description: "Delivered harness event type";
|
|
1155
1166
|
};
|
|
1156
1167
|
readonly "pi.lane.name": {
|
|
@@ -1167,44 +1178,54 @@ export declare const AGENT_TELEMETRY_SCHEMAS: readonly [{
|
|
|
1167
1178
|
};
|
|
1168
1179
|
};
|
|
1169
1180
|
readonly "pi.session.write": {
|
|
1170
|
-
readonly description: "One committed session
|
|
1181
|
+
readonly description: "One committed session transaction";
|
|
1171
1182
|
readonly parents: {
|
|
1172
1183
|
readonly kind: "any";
|
|
1173
1184
|
};
|
|
1174
1185
|
readonly startAttributes: {
|
|
1175
|
-
readonly "pi.
|
|
1186
|
+
readonly "pi.session.id": {
|
|
1176
1187
|
readonly type: "string";
|
|
1177
1188
|
readonly required: true;
|
|
1178
1189
|
readonly cardinality: "high";
|
|
1179
|
-
readonly description: "
|
|
1190
|
+
readonly description: "Session id";
|
|
1180
1191
|
};
|
|
1181
|
-
readonly "pi.
|
|
1192
|
+
readonly "pi.lane.name": {
|
|
1182
1193
|
readonly type: "string";
|
|
1183
1194
|
readonly required: false;
|
|
1184
1195
|
readonly cardinality: "high";
|
|
1185
|
-
readonly description: "
|
|
1196
|
+
readonly description: "Lane name when supplied by the caller";
|
|
1186
1197
|
};
|
|
1187
|
-
readonly "pi.
|
|
1198
|
+
readonly "pi.operation.id": {
|
|
1188
1199
|
readonly type: "string";
|
|
1200
|
+
readonly required: false;
|
|
1201
|
+
readonly cardinality: "high";
|
|
1202
|
+
readonly description: "Durable operation id when supplied by the caller";
|
|
1203
|
+
};
|
|
1204
|
+
readonly "pi.session.item_count": {
|
|
1205
|
+
readonly type: "number";
|
|
1189
1206
|
readonly required: true;
|
|
1190
|
-
readonly
|
|
1191
|
-
readonly description: "Session mutation kind";
|
|
1207
|
+
readonly description: "Number of writes in the transaction";
|
|
1192
1208
|
};
|
|
1193
|
-
readonly "pi.session.
|
|
1194
|
-
readonly type: "string";
|
|
1195
|
-
readonly required:
|
|
1196
|
-
readonly
|
|
1209
|
+
readonly "pi.session.item_kinds": {
|
|
1210
|
+
readonly type: "string[]";
|
|
1211
|
+
readonly required: true;
|
|
1212
|
+
readonly elementValues: readonly ["entry", "usage", "value", "list"];
|
|
1213
|
+
readonly description: "Distinct write kinds in the transaction";
|
|
1197
1214
|
};
|
|
1198
1215
|
};
|
|
1199
1216
|
readonly endAttributes: {
|
|
1200
|
-
readonly "pi.session.
|
|
1217
|
+
readonly "pi.session.first_seq": {
|
|
1218
|
+
readonly type: "number";
|
|
1219
|
+
readonly description: "First committed sequence in the transaction";
|
|
1220
|
+
};
|
|
1221
|
+
readonly "pi.session.last_seq": {
|
|
1201
1222
|
readonly type: "number";
|
|
1202
|
-
readonly description: "
|
|
1223
|
+
readonly description: "Last committed sequence in the transaction";
|
|
1203
1224
|
};
|
|
1204
1225
|
};
|
|
1205
1226
|
readonly status: {
|
|
1206
1227
|
readonly default: "ok";
|
|
1207
|
-
readonly errorWhen: "Storage rejects the
|
|
1228
|
+
readonly errorWhen: "Storage rejects the transaction";
|
|
1208
1229
|
};
|
|
1209
1230
|
};
|
|
1210
1231
|
};
|
|
@@ -1217,5 +1238,5 @@ export type HarnessSpanEventName<Name extends HarnessSpanName> = TelemetrySchema
|
|
|
1217
1238
|
export type HarnessSpanEventAttributes<Name extends HarnessSpanName, EventName extends HarnessSpanEventName<Name>> = TelemetrySchemaSpanEventAttributes<typeof HARNESS_TELEMETRY_SCHEMA, Name, EventName>;
|
|
1218
1239
|
export type HarnessTelemetrySpan<Name extends HarnessSpanName> = SchemaTelemetrySpan<typeof HARNESS_TELEMETRY_SCHEMA, Name>;
|
|
1219
1240
|
export type HarnessSpan = TelemetrySchemaSpanUnion<typeof HARNESS_TELEMETRY_SCHEMA>;
|
|
1220
|
-
export declare function startHarnessSpan<Name extends HarnessSpanName, const Attributes extends HarnessSpanStartAttributes<Name>, Result>(
|
|
1241
|
+
export declare function startHarnessSpan<Name extends HarnessSpanName, const Attributes extends HarnessSpanStartAttributes<Name>, Result>(name: Name, attributes: ExactTelemetryAttributes<HarnessSpanStartAttributes<Name>, Attributes>, callback: (span: HarnessTelemetrySpan<Name>, context: Context) => Result | Promise<Result>, context: Context): Promise<Result>;
|
|
1221
1242
|
//# sourceMappingURL=telemetry.d.ts.map
|