@punks/cli 2.6.1 → 3.0.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/AGENTS.md +1 -1
- package/README.md +44 -24
- package/dist/BASELINE_CHANGELOG.md +57 -0
- package/dist/CHANGELOG.md +83 -0
- package/dist/data/scripts/harness-projection/adapters/claude.d.mts +3 -0
- package/dist/data/scripts/harness-projection/adapters/claude.mjs +124 -0
- package/dist/data/scripts/harness-projection/adapters/codex.d.mts +3 -0
- package/dist/data/scripts/harness-projection/adapters/codex.mjs +137 -0
- package/dist/data/scripts/harness-projection/adapters/cursor.d.mts +5 -0
- package/dist/data/scripts/harness-projection/adapters/cursor.mjs +106 -0
- package/dist/data/scripts/harness-projection/adapters/opencode.d.mts +5 -0
- package/dist/data/scripts/harness-projection/adapters/opencode.mjs +100 -0
- package/dist/data/scripts/harness-projection/apply.d.mts +12 -0
- package/dist/data/scripts/harness-projection/apply.mjs +96 -0
- package/dist/data/scripts/harness-projection/core.d.mts +8 -0
- package/dist/data/scripts/harness-projection/core.mjs +239 -0
- package/dist/data/scripts/harness-projection/test-fixtures/application-context-plan.json +27 -0
- package/dist/data/scripts/harness-projection/test-fixtures/claude/actions.json +109 -0
- package/dist/data/scripts/harness-projection/test-fixtures/claude/context-plan.json +150 -0
- package/dist/data/scripts/harness-projection/test-fixtures/claude/matrix.json +23 -0
- package/dist/data/scripts/harness-projection/test-fixtures/claude/traces.json +15 -0
- package/dist/data/scripts/harness-projection/test-fixtures/codex/actions.json +124 -0
- package/dist/data/scripts/harness-projection/test-fixtures/codex/context-plan.json +150 -0
- package/dist/data/scripts/harness-projection/test-fixtures/codex/matrix.json +23 -0
- package/dist/data/scripts/harness-projection/test-fixtures/codex/traces.json +15 -0
- package/dist/data/scripts/harness-projection/test-fixtures/cursor/compiler-input.json +93 -0
- package/dist/data/scripts/harness-projection/test-fixtures/cursor/context-plan.json +108 -0
- package/dist/data/scripts/harness-projection/test-fixtures/cursor/matrix.json +19 -0
- package/dist/data/scripts/harness-projection/test-fixtures/cursor/projection.json +54 -0
- package/dist/data/scripts/harness-projection/test-fixtures/mixed-context-plan.json +35 -0
- package/dist/data/scripts/harness-projection/test-fixtures/opencode/compiler-input.json +93 -0
- package/dist/data/scripts/harness-projection/test-fixtures/opencode/context-plan.json +108 -0
- package/dist/data/scripts/harness-projection/test-fixtures/opencode/matrix.json +19 -0
- package/dist/data/scripts/harness-projection/test-fixtures/opencode/projection.json +51 -0
- package/dist/data/scripts/sync-subagents.mjs +1113 -33
- package/dist/data/subagents/manifest.mjs +5 -6
- package/dist/index.js +1373 -62672
- package/dist/skills/agnostic/cli/hi-cli/SKILL.md +17 -121
- package/dist/skills/agnostic/cli/hi-cli/references/commands.md +32 -47
- package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +73 -62
- package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +1 -1
- package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +2 -2
- package/dist/skills/agnostic/planning/create-plan/SKILL.md +11 -10
- package/dist/skills/agnostic/planning/create-plan/references/grill-ambiguity.md +10 -31
- package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +2 -2
- package/dist/skills/agnostic/planning/create-spec/SKILL.md +3 -5
- package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +1 -0
- package/dist/skills/agnostic/planning/create-spec/references/backlog-sync.md +2 -2
- package/dist/skills/agnostic/planning/create-spec/references/grill-phase.md +4 -9
- package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +1 -0
- package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +1 -1
- package/dist/skills/agnostic/requirements/grilling/LICENSE +21 -0
- package/dist/skills/agnostic/requirements/grilling/SKILL.md +6 -30
- package/dist/skills/agnostic/requirements/grilling/UPSTREAM.md +16 -0
- package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +3 -5
- package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +40 -16
- package/dist/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +3 -16
- package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +21 -15
- package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +14 -14
- package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +28 -9
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +45 -5
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +48 -28
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +22 -6
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +47 -22
- package/dist/skills/frameworks/effect/effect/LICENSE +21 -0
- package/dist/skills/frameworks/effect/effect/SKILL.md +100 -0
- package/dist/skills/frameworks/effect/effect/UPSTREAM.md +11 -0
- package/dist/skills/frameworks/effect/effect/references/CACHING.md +76 -0
- package/dist/skills/frameworks/effect/effect/references/CONFIG.md +67 -0
- package/dist/skills/frameworks/effect/effect/references/HTTP_CLIENTS.md +101 -0
- package/dist/skills/frameworks/effect/{effect-authoring/references/otel-patterns.md → effect/references/OBSERVABILITY.md} +4 -29
- package/dist/skills/frameworks/effect/effect/references/SCHEDULING.md +135 -0
- package/dist/skills/frameworks/effect/effect/references/SCHEMA.md +130 -0
- package/dist/skills/frameworks/effect/effect/references/SERVICES_LAYERS.md +168 -0
- package/dist/skills/frameworks/effect/effect/references/STREAMS.md +135 -0
- package/dist/skills/frameworks/effect/effect/references/TESTING.md +118 -0
- package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +7 -8
- package/dist/skills/frameworks/effect/effect-recoverable-actions/SKILL.md +1 -1
- package/dist/skills/frameworks/nestjs/nestjs-best-practices/.gitignore +29 -0
- package/dist/skills/misc/secrets-cli/SKILL.md +54 -0
- package/dist/skills/misc/secrets-cli/references/command-reference.md +107 -0
- package/dist/skills/misc/secrets-cli/references/safety-and-errors.md +54 -0
- package/dist/skills/misc/secrets-cli/references/workflows.md +106 -0
- package/dist/skills/phases/design-phase/phases/grill.md +1 -1
- package/dist/skills/phases/requirements-phase/SKILL.md +2 -4
- package/dist/skills/phases/review-phase/REFERENCE.md +13 -5
- package/dist/skills/phases/review-phase/SKILL.md +3 -2
- package/package.json +1 -1
- package/dist/skills/agnostic/planning/create-spec/references/handoff.md +0 -47
- package/dist/skills/frameworks/effect/effect-authoring/SKILL.md +0 -116
- package/dist/skills/frameworks/effect/effect-authoring/references/branded-types.md +0 -98
- package/dist/skills/frameworks/effect/effect-authoring/references/effect-primitives.md +0 -144
- package/dist/skills/frameworks/effect/effect-authoring/references/error-patterns.md +0 -156
- package/dist/skills/frameworks/effect/effect-authoring/references/test-patterns.md +0 -146
- package/dist/skills/frameworks/effect/effect-best-practices/SKILL.md +0 -517
- package/dist/skills/frameworks/effect/effect-best-practices/references/anti-patterns.md +0 -392
- package/dist/skills/frameworks/effect/effect-best-practices/references/effect-atom-patterns.md +0 -653
- package/dist/skills/frameworks/effect/effect-best-practices/references/error-patterns.md +0 -464
- package/dist/skills/frameworks/effect/effect-best-practices/references/language-server.md +0 -287
- package/dist/skills/frameworks/effect/effect-best-practices/references/layer-patterns.md +0 -495
- package/dist/skills/frameworks/effect/effect-best-practices/references/observability-patterns.md +0 -342
- package/dist/skills/frameworks/effect/effect-best-practices/references/rpc-cluster-patterns.md +0 -418
- package/dist/skills/frameworks/effect/effect-best-practices/references/schema-patterns.md +0 -353
- package/dist/skills/frameworks/effect/effect-best-practices/references/service-patterns.md +0 -299
- /package/dist/skills/frameworks/effect/{effect-authoring/references/effect-atom-patterns.md → effect/references/EFFECT_ATOM.md} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export const cursorCapabilityMatrix = {
|
|
2
|
+
matrixVersion: "2026.07.17-v1",
|
|
3
|
+
adapter: { id: "cursor", version: "1.0.0" },
|
|
4
|
+
capabilities: [
|
|
5
|
+
{ family: "skill", support: "supported" },
|
|
6
|
+
{ family: "scoped-prompt", support: "supported" },
|
|
7
|
+
{
|
|
8
|
+
family: "lifecycle-hook",
|
|
9
|
+
support: "degraded",
|
|
10
|
+
reason: "Only session-start and file-edit command hooks have native Cursor projections",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
family: "tool-configuration",
|
|
14
|
+
support: "unsupported",
|
|
15
|
+
reason: "Harness tool configuration is not projected into Cursor settings",
|
|
16
|
+
},
|
|
17
|
+
{ family: "subagent-template", support: "supported" },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const hookConfig = new Map([
|
|
22
|
+
[
|
|
23
|
+
"scaffold-update-check",
|
|
24
|
+
{
|
|
25
|
+
event: "sessionStart",
|
|
26
|
+
command: "node .cursor/hooks/scaffold-update-check.mjs cursor",
|
|
27
|
+
timeout: 60000,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"format-edited-file",
|
|
32
|
+
{
|
|
33
|
+
event: "afterFileEdit",
|
|
34
|
+
command: "node .cursor/hooks/format-edited-file.mjs cursor",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const cursorProject = ({ scopeId, contribution }) => {
|
|
40
|
+
const contributionId = contribution.identity.id;
|
|
41
|
+
|
|
42
|
+
switch (contribution.kind) {
|
|
43
|
+
case "skill":
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
id: `cursor:skill:${scopeId}:${contributionId}`,
|
|
47
|
+
operation: "native",
|
|
48
|
+
source: `.agents/skills/${contributionId}/SKILL.md`,
|
|
49
|
+
contributionId,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
case "scoped-prompt": {
|
|
53
|
+
const target =
|
|
54
|
+
scopeId === ".agents" || scopeId === "shared"
|
|
55
|
+
? ".agents/AGENTS.md"
|
|
56
|
+
: scopeId === "root"
|
|
57
|
+
? "AGENTS.md"
|
|
58
|
+
: `${scopeId}/AGENTS.md`;
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
id: `cursor:scoped-prompt:${scopeId}:${contributionId}`,
|
|
62
|
+
operation: "native",
|
|
63
|
+
source: target,
|
|
64
|
+
target,
|
|
65
|
+
contributionId,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
case "lifecycle-hook": {
|
|
70
|
+
const config = hookConfig.get(contributionId);
|
|
71
|
+
if (config === undefined) {
|
|
72
|
+
return {
|
|
73
|
+
_tag: "HarnessProjectionUnsupported",
|
|
74
|
+
reason: `Cursor lifecycle hook ${contributionId} has no native projection`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
id: `cursor:lifecycle-hook:${scopeId}:${contributionId}`,
|
|
80
|
+
operation: "mirror",
|
|
81
|
+
source: `.agents/hooks/${contributionId}.mjs`,
|
|
82
|
+
target: `.cursor/hooks/${contributionId}.mjs`,
|
|
83
|
+
config: { path: ".cursor/hooks.json", ...config },
|
|
84
|
+
contributionId,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
case "subagent-template":
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
id: `cursor:subagent-template:${scopeId}:${contributionId}`,
|
|
92
|
+
operation: "render",
|
|
93
|
+
target: `.cursor/agents/${contributionId}.md`,
|
|
94
|
+
format: "cursor-subagent-v1",
|
|
95
|
+
contributionId,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
default:
|
|
99
|
+
throw new Error(`Cursor received non-projectable ${contribution.kind} contribution`);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const cursorAdapter = {
|
|
104
|
+
matrix: cursorCapabilityMatrix,
|
|
105
|
+
project: cursorProject,
|
|
106
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HarnessCapabilityMatrix } from "@punks/scaffold/harness-capability";
|
|
2
|
+
import type { HarnessProjectionAdapter } from "../contract";
|
|
3
|
+
|
|
4
|
+
export declare const openCodeAdapter: HarnessProjectionAdapter;
|
|
5
|
+
export declare const openCodeCapabilityMatrix: HarnessCapabilityMatrix;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const openCodeCapabilityMatrix = {
|
|
2
|
+
matrixVersion: "2026.07.17-v1",
|
|
3
|
+
adapter: { id: "opencode", version: "1.0.0" },
|
|
4
|
+
capabilities: [
|
|
5
|
+
{ family: "skill", support: "supported" },
|
|
6
|
+
{ family: "scoped-prompt", support: "supported" },
|
|
7
|
+
{
|
|
8
|
+
family: "lifecycle-hook",
|
|
9
|
+
support: "degraded",
|
|
10
|
+
reason: "Only the formatter hook has a native OpenCode lifecycle projection",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
family: "tool-configuration",
|
|
14
|
+
support: "unsupported",
|
|
15
|
+
reason: "Harness-required CLI tools are operator prerequisites, not OpenCode configuration",
|
|
16
|
+
},
|
|
17
|
+
{ family: "subagent-template", support: "supported" },
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const openCodeProject = ({ scopeId, contribution }) => {
|
|
22
|
+
const contributionId = contribution.identity.id;
|
|
23
|
+
|
|
24
|
+
switch (contribution.kind) {
|
|
25
|
+
case "skill":
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
id: `opencode:skill:${scopeId}:${contributionId}`,
|
|
29
|
+
operation: "native",
|
|
30
|
+
source: `.agents/skills/${contributionId}/SKILL.md`,
|
|
31
|
+
contributionId,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
case "scoped-prompt": {
|
|
35
|
+
const source =
|
|
36
|
+
scopeId === ".agents" || scopeId === "shared"
|
|
37
|
+
? ".agents/AGENTS.md"
|
|
38
|
+
: scopeId === "root"
|
|
39
|
+
? "AGENTS.md"
|
|
40
|
+
: `${scopeId}/AGENTS.md`;
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
id: `opencode:scoped-prompt:${scopeId}:${contributionId}`,
|
|
44
|
+
operation: scopeId === ".agents" || scopeId === "shared" ? "mirror" : "native",
|
|
45
|
+
source,
|
|
46
|
+
target: scopeId === ".agents" || scopeId === "shared" ? ".opencode/AGENTS.md" : source,
|
|
47
|
+
contributionId,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
case "lifecycle-hook":
|
|
52
|
+
if (contributionId !== "format-edited-file") {
|
|
53
|
+
return {
|
|
54
|
+
_tag: "HarnessProjectionUnsupported",
|
|
55
|
+
reason: `OpenCode lifecycle hook ${contributionId} has no native projection`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
id: `opencode:lifecycle-hook:${scopeId}:${contributionId}:mirror`,
|
|
61
|
+
operation: "mirror",
|
|
62
|
+
source: `.agents/hooks/${contributionId}.mjs`,
|
|
63
|
+
target: `.opencode/plugins/${contributionId}.mjs`,
|
|
64
|
+
contributionId,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: `opencode:lifecycle-hook:${scopeId}:${contributionId}:configure`,
|
|
68
|
+
operation: "merge-json",
|
|
69
|
+
target: "opencode.json",
|
|
70
|
+
value: {
|
|
71
|
+
$schema: "https://opencode.ai/config.json",
|
|
72
|
+
formatter: {
|
|
73
|
+
"harness-format-edited-file": {
|
|
74
|
+
command: ["node", ".agents/hooks/format-edited-file.mjs", "files", "$FILE"],
|
|
75
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".json", ".py"],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
contributionId,
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
case "subagent-template":
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
id: `opencode:subagent-template:${scopeId}:${contributionId}`,
|
|
86
|
+
operation: "render",
|
|
87
|
+
target: `.opencode/agents/${contributionId}.md`,
|
|
88
|
+
format: "opencode-subagent-v1",
|
|
89
|
+
contributionId,
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
default:
|
|
93
|
+
throw new Error(`OpenCode received non-projectable ${contribution.kind} contribution`);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const openCodeAdapter = {
|
|
98
|
+
matrix: openCodeCapabilityMatrix,
|
|
99
|
+
project: openCodeProject,
|
|
100
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HarnessProjectionSummary } from "@punks/scaffold/harness-capability";
|
|
2
|
+
|
|
3
|
+
import type { ApplicationAction, ApplicationProjectionResult, ProjectionIntent } from "./contract";
|
|
4
|
+
|
|
5
|
+
export interface ProjectionFilesystem<Intent extends ProjectionIntent = ProjectionIntent> {
|
|
6
|
+
readonly apply: (action: ApplicationAction<Intent>) => Promise<void> | void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare function applyProjection<Intent extends ProjectionIntent>(input: {
|
|
10
|
+
readonly projection: ApplicationProjectionResult<Intent>;
|
|
11
|
+
readonly filesystem: ProjectionFilesystem<Intent>;
|
|
12
|
+
}): Promise<HarnessProjectionSummary>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const traceKey = (trace) =>
|
|
2
|
+
("contribution" in trace
|
|
3
|
+
? [
|
|
4
|
+
trace.contextPlanVersion,
|
|
5
|
+
"contribution",
|
|
6
|
+
trace.scopeId,
|
|
7
|
+
trace.kind,
|
|
8
|
+
trace.contribution.id,
|
|
9
|
+
trace.contribution.version,
|
|
10
|
+
trace.adapter.id,
|
|
11
|
+
trace.adapter.version,
|
|
12
|
+
trace.matrixVersion,
|
|
13
|
+
]
|
|
14
|
+
: [
|
|
15
|
+
trace.contextPlanVersion,
|
|
16
|
+
"application",
|
|
17
|
+
trace.operation,
|
|
18
|
+
trace.adapter.id,
|
|
19
|
+
trace.adapter.version,
|
|
20
|
+
trace.matrixVersion,
|
|
21
|
+
]
|
|
22
|
+
).join("\u0000");
|
|
23
|
+
|
|
24
|
+
const projectionState = (summary) =>
|
|
25
|
+
summary._tag === "HarnessProjectionFailure"
|
|
26
|
+
? {
|
|
27
|
+
applied: summary.completed,
|
|
28
|
+
omissions: summary.omissions,
|
|
29
|
+
errors: [...summary.errors],
|
|
30
|
+
}
|
|
31
|
+
: {
|
|
32
|
+
applied: summary.applied,
|
|
33
|
+
omissions: summary._tag === "HarnessProjectionPartial" ? summary.omissions : [],
|
|
34
|
+
errors: [],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export async function applyProjection({ projection, filesystem }) {
|
|
38
|
+
const state = projectionState(projection.summary);
|
|
39
|
+
const failed = new Set();
|
|
40
|
+
const failedLifecycleHooks = new Set();
|
|
41
|
+
|
|
42
|
+
for (const action of projection.actions) {
|
|
43
|
+
try {
|
|
44
|
+
const reconciledAction =
|
|
45
|
+
action.operation === "reconcile-lifecycle-hooks"
|
|
46
|
+
? {
|
|
47
|
+
...action,
|
|
48
|
+
configurations: action.configurations.filter(
|
|
49
|
+
(configuration) => !failed.has(traceKey(configuration.trace)),
|
|
50
|
+
),
|
|
51
|
+
hookIds: action.hookIds.filter((hookId) => !failedLifecycleHooks.has(hookId)),
|
|
52
|
+
}
|
|
53
|
+
: action;
|
|
54
|
+
await filesystem.apply(reconciledAction);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
failed.add(traceKey(action.trace));
|
|
57
|
+
if (action.operation === "reconcile-lifecycle-hooks") {
|
|
58
|
+
for (const hookId of action.hookIds) {
|
|
59
|
+
failedLifecycleHooks.add(hookId);
|
|
60
|
+
for (const outcome of state.applied) {
|
|
61
|
+
if (
|
|
62
|
+
"contribution" in outcome.trace &&
|
|
63
|
+
outcome.trace.kind === "lifecycle-hook" &&
|
|
64
|
+
outcome.trace.contribution.id === hookId
|
|
65
|
+
) {
|
|
66
|
+
failed.add(traceKey(outcome.trace));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const configuration of action.configurations) {
|
|
71
|
+
failed.add(traceKey(configuration.trace));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (action.id.includes(":lifecycle-hook:") && "contribution" in action.trace) {
|
|
75
|
+
failedLifecycleHooks.add(action.trace.contribution.id);
|
|
76
|
+
}
|
|
77
|
+
state.errors.push({
|
|
78
|
+
_tag: "HarnessApplicationFailureError",
|
|
79
|
+
trace: action.trace,
|
|
80
|
+
action: action.id,
|
|
81
|
+
message: error instanceof Error ? error.message : "Application failed",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (state.errors.length > 0) {
|
|
87
|
+
return {
|
|
88
|
+
_tag: "HarnessProjectionFailure",
|
|
89
|
+
completed: state.applied.filter(({ trace }) => !failed.has(traceKey(trace))),
|
|
90
|
+
omissions: state.omissions,
|
|
91
|
+
errors: state.errors,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return projection.summary;
|
|
96
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ContextPlan } from "@punks/scaffold/context-plan";
|
|
2
|
+
|
|
3
|
+
import type { HarnessProjectionAdapter, ProjectionIntent, ProjectionResult } from "./contract";
|
|
4
|
+
|
|
5
|
+
export declare function project<Intent extends ProjectionIntent>(input: {
|
|
6
|
+
readonly adapter: HarnessProjectionAdapter<Intent>;
|
|
7
|
+
readonly contextPlan: ContextPlan;
|
|
8
|
+
}): ProjectionResult<Intent>;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const nonEmptyString = (value, fallback = "unknown") =>
|
|
2
|
+
typeof value === "string" && value.length > 0 ? value : fallback;
|
|
3
|
+
|
|
4
|
+
const adapterIdentity = (matrix) => ({
|
|
5
|
+
id: nonEmptyString(matrix?.adapter?.id),
|
|
6
|
+
version: nonEmptyString(matrix?.adapter?.version),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const traceFor = ({ adapter, contextPlan, scope, contribution }) => ({
|
|
10
|
+
contextPlanVersion: nonEmptyString(contextPlan?.version),
|
|
11
|
+
scopeId: nonEmptyString(scope?.id),
|
|
12
|
+
kind: nonEmptyString(contribution?.kind, "skill"),
|
|
13
|
+
contribution: {
|
|
14
|
+
id: nonEmptyString(contribution?.identity?.id, "context-plan"),
|
|
15
|
+
version: nonEmptyString(contribution?.identity?.version),
|
|
16
|
+
},
|
|
17
|
+
adapter: adapterIdentity(adapter?.matrix),
|
|
18
|
+
matrixVersion: nonEmptyString(adapter?.matrix?.matrixVersion),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const capabilityFamilies = [
|
|
22
|
+
"skill",
|
|
23
|
+
"scoped-prompt",
|
|
24
|
+
"lifecycle-hook",
|
|
25
|
+
"tool-configuration",
|
|
26
|
+
"subagent-template",
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
|
|
31
|
+
const capabilityRowIssue = (row) => {
|
|
32
|
+
const allowedKeys =
|
|
33
|
+
row.support === "supported" ? ["family", "support"] : ["family", "support", "reason"];
|
|
34
|
+
if (Object.keys(row).some((key) => !allowedKeys.includes(key))) {
|
|
35
|
+
return `Adapter matrix capability for ${row.family} has unexpected fields`;
|
|
36
|
+
}
|
|
37
|
+
if (row.support === "supported") {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (
|
|
41
|
+
(row.support === "degraded" || row.support === "unsupported") &&
|
|
42
|
+
typeof row.reason === "string" &&
|
|
43
|
+
row.reason.length > 0
|
|
44
|
+
) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return `Adapter matrix capability for ${row.family} has invalid support`;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const validateCapabilityMatrix = (matrix) => {
|
|
51
|
+
const metadataIssues = [];
|
|
52
|
+
if (!isObject(matrix)) {
|
|
53
|
+
metadataIssues.push("Adapter matrix must be an object");
|
|
54
|
+
} else {
|
|
55
|
+
if (typeof matrix.matrixVersion !== "string" || matrix.matrixVersion.length === 0) {
|
|
56
|
+
metadataIssues.push("Adapter matrix version must be a non-empty string");
|
|
57
|
+
}
|
|
58
|
+
if (!isObject(matrix.adapter)) {
|
|
59
|
+
metadataIssues.push("Adapter identity must be an object");
|
|
60
|
+
} else {
|
|
61
|
+
if (typeof matrix.adapter.id !== "string" || matrix.adapter.id.length === 0) {
|
|
62
|
+
metadataIssues.push("Adapter id must be a non-empty string");
|
|
63
|
+
}
|
|
64
|
+
if (typeof matrix.adapter.version !== "string" || matrix.adapter.version.length === 0) {
|
|
65
|
+
metadataIssues.push("Adapter version must be a non-empty string");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!isObject(matrix) || !Array.isArray(matrix.capabilities)) {
|
|
70
|
+
return {
|
|
71
|
+
capabilities: new Map(),
|
|
72
|
+
globalIssue: [...metadataIssues, "Adapter matrix capabilities must be an array"].join("; "),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const unknownRows = matrix.capabilities.filter(
|
|
77
|
+
(row) => !isObject(row) || !capabilityFamilies.includes(row.family),
|
|
78
|
+
);
|
|
79
|
+
if (unknownRows.length > 0) {
|
|
80
|
+
return {
|
|
81
|
+
capabilities: new Map(),
|
|
82
|
+
globalIssue: [
|
|
83
|
+
...metadataIssues,
|
|
84
|
+
"Adapter matrix contains an unknown or malformed capability row",
|
|
85
|
+
].join("; "),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const familyIssues = new Map();
|
|
90
|
+
const validRows = [];
|
|
91
|
+
for (const family of capabilityFamilies) {
|
|
92
|
+
const rows = matrix.capabilities.filter((row) => row.family === family);
|
|
93
|
+
if (rows.length !== 1) {
|
|
94
|
+
familyIssues.set(
|
|
95
|
+
family,
|
|
96
|
+
`Adapter matrix must contain exactly one capability for ${family}; found ${rows.length}`,
|
|
97
|
+
);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const issue = capabilityRowIssue(rows[0]);
|
|
102
|
+
if (issue === undefined) {
|
|
103
|
+
validRows.push(rows[0]);
|
|
104
|
+
} else {
|
|
105
|
+
familyIssues.set(family, issue);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const globalIssue = [...metadataIssues, ...familyIssues.values()].join("; ") || undefined;
|
|
110
|
+
return {
|
|
111
|
+
capabilities:
|
|
112
|
+
globalIssue === undefined ? new Map(validRows.map((row) => [row.family, row])) : new Map(),
|
|
113
|
+
globalIssue,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export function project({ adapter, contextPlan }) {
|
|
118
|
+
const { capabilities, globalIssue } = validateCapabilityMatrix(adapter.matrix);
|
|
119
|
+
const actions = [];
|
|
120
|
+
const applied = [];
|
|
121
|
+
const omissions = [];
|
|
122
|
+
const errors = [];
|
|
123
|
+
let contributionCount = 0;
|
|
124
|
+
|
|
125
|
+
for (const scope of contextPlan.scopes) {
|
|
126
|
+
for (const contribution of scope.contributions) {
|
|
127
|
+
contributionCount += 1;
|
|
128
|
+
const capability = capabilities.get(contribution.kind);
|
|
129
|
+
const trace = traceFor({ adapter, contextPlan, scope, contribution });
|
|
130
|
+
|
|
131
|
+
if (globalIssue !== undefined) {
|
|
132
|
+
errors.push({
|
|
133
|
+
_tag: "InvalidHarnessProjectionError",
|
|
134
|
+
trace,
|
|
135
|
+
message: globalIssue,
|
|
136
|
+
});
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (capability.support === "unsupported") {
|
|
141
|
+
omissions.push({
|
|
142
|
+
_tag: "HarnessProjectionOmission",
|
|
143
|
+
support: "unsupported",
|
|
144
|
+
trace,
|
|
145
|
+
warning: {
|
|
146
|
+
_tag: "UnsupportedHarnessCapabilityWarning",
|
|
147
|
+
family: contribution.kind,
|
|
148
|
+
reason: capability.reason,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let projected;
|
|
155
|
+
try {
|
|
156
|
+
projected = adapter.project({ scopeId: scope.id, contribution, capability });
|
|
157
|
+
} catch (error) {
|
|
158
|
+
errors.push({
|
|
159
|
+
_tag: "HarnessAdapterDefectError",
|
|
160
|
+
trace,
|
|
161
|
+
message: error instanceof Error ? error.message : "Adapter defect",
|
|
162
|
+
});
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (
|
|
167
|
+
isObject(projected) &&
|
|
168
|
+
projected._tag === "HarnessProjectionUnsupported" &&
|
|
169
|
+
typeof projected.reason === "string" &&
|
|
170
|
+
projected.reason.length > 0
|
|
171
|
+
) {
|
|
172
|
+
if (capability.support !== "degraded") {
|
|
173
|
+
errors.push({
|
|
174
|
+
_tag: "InvalidHarnessProjectionError",
|
|
175
|
+
trace,
|
|
176
|
+
message: "Adapter declared unsupported for a supported capability",
|
|
177
|
+
});
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
omissions.push({
|
|
181
|
+
_tag: "HarnessProjectionOmission",
|
|
182
|
+
support: "unsupported",
|
|
183
|
+
trace,
|
|
184
|
+
warning: {
|
|
185
|
+
_tag: "UnsupportedHarnessCapabilityWarning",
|
|
186
|
+
family: contribution.kind,
|
|
187
|
+
reason: projected.reason,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (
|
|
194
|
+
!Array.isArray(projected) ||
|
|
195
|
+
projected.length === 0 ||
|
|
196
|
+
projected.some(
|
|
197
|
+
(action) =>
|
|
198
|
+
typeof action !== "object" ||
|
|
199
|
+
action === null ||
|
|
200
|
+
typeof action.id !== "string" ||
|
|
201
|
+
action.id.length === 0,
|
|
202
|
+
)
|
|
203
|
+
) {
|
|
204
|
+
errors.push({
|
|
205
|
+
_tag: "InvalidHarnessProjectionError",
|
|
206
|
+
trace,
|
|
207
|
+
message: "Adapter must return at least one identified action",
|
|
208
|
+
});
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
actions.push(...projected.map((action) => ({ ...action, trace })));
|
|
213
|
+
applied.push({
|
|
214
|
+
_tag: "HarnessProjectionApplied",
|
|
215
|
+
support: capability.support,
|
|
216
|
+
trace,
|
|
217
|
+
...(capability.support === "degraded" ? { reason: capability.reason } : {}),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (globalIssue !== undefined && contributionCount === 0) {
|
|
223
|
+
errors.push({
|
|
224
|
+
_tag: "InvalidHarnessProjectionError",
|
|
225
|
+
trace: traceFor({ adapter, contextPlan }),
|
|
226
|
+
message: globalIssue,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
actions,
|
|
232
|
+
summary:
|
|
233
|
+
errors.length > 0
|
|
234
|
+
? { _tag: "HarnessProjectionFailure", completed: applied, omissions, errors }
|
|
235
|
+
: omissions.length === 0
|
|
236
|
+
? { _tag: "HarnessProjectionSuccess", applied }
|
|
237
|
+
: { _tag: "HarnessProjectionPartial", applied, omissions },
|
|
238
|
+
};
|
|
239
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1",
|
|
3
|
+
"scopes": [
|
|
4
|
+
{
|
|
5
|
+
"id": "root",
|
|
6
|
+
"packs": [],
|
|
7
|
+
"contributions": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "skill",
|
|
10
|
+
"identity": { "id": "first", "version": "1.0.0" },
|
|
11
|
+
"provenance": { "source": "baseline", "revision": "2026.07.16" },
|
|
12
|
+
"compatibility": [],
|
|
13
|
+
"references": [],
|
|
14
|
+
"order": 0
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"kind": "skill",
|
|
18
|
+
"identity": { "id": "second", "version": "1.0.0" },
|
|
19
|
+
"provenance": { "source": "baseline", "revision": "2026.07.16" },
|
|
20
|
+
"compatibility": [],
|
|
21
|
+
"references": [],
|
|
22
|
+
"order": 1
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|