@aaac/runtime 0.2.9 → 0.3.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/dist/adapters/adk-sdk.d.ts +1 -1
- package/dist/adapters/adk-sdk.js +1 -1
- package/dist/adapters/claude-agent-sdk.d.ts +1 -1
- package/dist/adapters/claude-agent-sdk.js +5 -4
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.js +1 -1
- package/dist/{chunk-D2UXESPT.js → chunk-2SG3TBI3.js} +4 -51
- package/dist/chunk-2SG3TBI3.js.map +1 -0
- package/dist/{chunk-Y7NORFFM.js → chunk-5ZDW4RP7.js} +2 -2
- package/dist/{chunk-GWNXNSGL.js → chunk-BHTHXGA3.js} +12 -9
- package/dist/chunk-BHTHXGA3.js.map +1 -0
- package/dist/{chunk-HR2Q64AO.js → chunk-EA4V5DVD.js} +29 -4
- package/dist/chunk-EA4V5DVD.js.map +1 -0
- package/dist/chunk-EBMQHLXY.js +61 -0
- package/dist/chunk-EBMQHLXY.js.map +1 -0
- package/dist/{chunk-QVMLALPF.js → chunk-GGBNVCPV.js} +5 -3
- package/dist/{chunk-QVMLALPF.js.map → chunk-GGBNVCPV.js.map} +1 -1
- package/dist/{chunk-CJLKKDKN.js → chunk-N2EA3TGS.js} +12 -12
- package/dist/{chunk-CJLKKDKN.js.map → chunk-N2EA3TGS.js.map} +1 -1
- package/dist/{chunk-MG7WSWJU.js → chunk-RTYJNZGT.js} +1 -1
- package/dist/chunk-RTYJNZGT.js.map +1 -0
- package/dist/claude-bundles/full.js +148 -148
- package/dist/claude-bundles/lean.js +5 -5
- package/dist/claude-bundles/prompt.js +2 -2
- package/dist/generator/index.d.ts +2 -2
- package/dist/generator/index.js +2 -2
- package/dist/{guardrail-hooks-B-qe4ebW.d.ts → guardrail-hooks-BgHe8PrP.d.ts} +6 -3
- package/dist/{hooks-lite-DvZu9Jhx.d.ts → hooks-lite-BtOGc2F_.d.ts} +12 -1
- package/dist/{index-C2DHitGz.d.ts → index-DeZsmlij.d.ts} +4 -1
- package/dist/index.d.ts +24 -5
- package/dist/index.js +144 -45
- package/dist/index.js.map +1 -1
- package/dist/lib/claude-native/hooks-lite.d.ts +2 -2
- package/dist/lib/claude-native/hooks-lite.js +6 -4
- package/dist/lib/claude-native/hooks-prompt.d.ts +3 -3
- package/dist/lib/claude-native/hooks-prompt.js +4 -3
- package/dist/lib/claude-native/index.d.ts +5 -5
- package/dist/lib/claude-native/index.js +11 -9
- package/dist/lib/claude-native/index.js.map +1 -1
- package/dist/{navigation-context-D1NbiipT.d.ts → navigation-context-DJjCkrcj.d.ts} +1 -1
- package/dist/{workspace-user-prompt-submit-aErGPoX4.d.ts → workspace-user-prompt-submit-GZwUKUHi.d.ts} +1 -1
- package/package.json +4 -4
- package/dist/chunk-D2UXESPT.js.map +0 -1
- package/dist/chunk-GWNXNSGL.js.map +0 -1
- package/dist/chunk-HR2Q64AO.js.map +0 -1
- package/dist/chunk-MG7WSWJU.js.map +0 -1
- /package/dist/{chunk-Y7NORFFM.js.map → chunk-5ZDW4RP7.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
resolveHandoffSchemas,
|
|
16
16
|
resolveNavigationDsl,
|
|
17
17
|
resolveNavigationSources
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-N2EA3TGS.js";
|
|
19
19
|
import {
|
|
20
20
|
jsonSchemaToZod
|
|
21
21
|
} from "./chunk-ET6TGQRT.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
AdapterError,
|
|
24
24
|
adapterErrorKind,
|
|
25
25
|
toolGrantForAgent
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RTYJNZGT.js";
|
|
27
27
|
import {
|
|
28
28
|
OBSERVABILITY_ENV_VARS,
|
|
29
29
|
buildObservabilityEnv,
|
|
@@ -52,11 +52,14 @@ import {
|
|
|
52
52
|
loadProjectConfig,
|
|
53
53
|
loadWorkspaceMembers,
|
|
54
54
|
readProjectManifest
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-5ZDW4RP7.js";
|
|
56
56
|
import {
|
|
57
57
|
isNavigationIndex,
|
|
58
58
|
renderNavigationIndexPrompt
|
|
59
59
|
} from "./chunk-3CLWG72V.js";
|
|
60
|
+
import {
|
|
61
|
+
editProtection
|
|
62
|
+
} from "./chunk-EBMQHLXY.js";
|
|
60
63
|
import {
|
|
61
64
|
UNRESOLVED_GUARDRAIL_ACTION,
|
|
62
65
|
createGuardrailHooks,
|
|
@@ -64,8 +67,9 @@ import {
|
|
|
64
67
|
getBlockingViolations,
|
|
65
68
|
getWarnings,
|
|
66
69
|
hasBlockingViolation,
|
|
67
|
-
toolTargetPath
|
|
68
|
-
|
|
70
|
+
toolTargetPath,
|
|
71
|
+
toolWriteTarget
|
|
72
|
+
} from "./chunk-EA4V5DVD.js";
|
|
69
73
|
import {
|
|
70
74
|
__commonJS,
|
|
71
75
|
__require,
|
|
@@ -9276,8 +9280,12 @@ async function evaluateGuardrail(opts) {
|
|
|
9276
9280
|
response = hooks.beforeShellExecution(shell);
|
|
9277
9281
|
checks = hooks.checkShellCommand(shell);
|
|
9278
9282
|
} else if (toolName !== void 0 || toolInput !== void 0) {
|
|
9279
|
-
response = hooks.preToolUse({
|
|
9280
|
-
|
|
9283
|
+
response = hooks.preToolUse({
|
|
9284
|
+
tool_name: toolName,
|
|
9285
|
+
tool_input: toolInput,
|
|
9286
|
+
root: opts.projectRoot
|
|
9287
|
+
});
|
|
9288
|
+
const checkFilePath = toolWriteTarget(toolName, toolInput, opts.projectRoot);
|
|
9281
9289
|
if (checkFilePath) {
|
|
9282
9290
|
checks = hooks.runChecks({ filePath: checkFilePath });
|
|
9283
9291
|
}
|
|
@@ -9437,27 +9445,79 @@ var ClaudeConfigSchema = z3.object({
|
|
|
9437
9445
|
* Reserved for future hook integration; validated for config parity.
|
|
9438
9446
|
*/
|
|
9439
9447
|
guard_command: z3.string().optional(),
|
|
9448
|
+
/**
|
|
9449
|
+
* The command that runs `syncClaude` for this project (e.g.
|
|
9450
|
+
* "npx dev-team claude sync"). The CLAUDE.md block and the banner on every
|
|
9451
|
+
* generated subagent and workflow file name it as the way to regenerate
|
|
9452
|
+
* them. Without it they name `syncClaude` itself: the component id is not a
|
|
9453
|
+
* command, so nothing else here says which executable runs the sync. The
|
|
9454
|
+
* project manifest's `bindings.claude.sync_command` wins over it
|
|
9455
|
+
* (`applyProjectBinding`).
|
|
9456
|
+
*/
|
|
9457
|
+
sync_command: z3.string().optional(),
|
|
9458
|
+
/**
|
|
9459
|
+
* The command that runs `checkClaude` for this project (e.g.
|
|
9460
|
+
* "npx dev-team claude check"), named in the CLAUDE.md block as the drift
|
|
9461
|
+
* check. Without it the block names `checkClaude` itself. The project
|
|
9462
|
+
* manifest's `bindings.claude.check_command` wins over it.
|
|
9463
|
+
*/
|
|
9464
|
+
check_command: z3.string().optional(),
|
|
9465
|
+
/**
|
|
9466
|
+
* Whether the project keeps the hook install out of version control. The
|
|
9467
|
+
* hook install is every file `syncClaude` renders for the navigation-index
|
|
9468
|
+
* hooks — `<output_dir>/settings.json`, `hooks/`, `bin/` and `cache/` — and
|
|
9469
|
+
* not the CLAUDE.md block. Default `false`: the install is committed, and
|
|
9470
|
+
* `checkClaude` reports any part of it that is absent as `missing`.
|
|
9471
|
+
*
|
|
9472
|
+
* When `true`, `checkClaude` lists an absent install file in `skipped`
|
|
9473
|
+
* instead of `drift`, so a fresh clone or a CI checkout gates the committed
|
|
9474
|
+
* artifacts (`agents`, `workflows`, `commands`, the CLAUDE.md block) and
|
|
9475
|
+
* nothing else. An install file that is present is compared as usual, and
|
|
9476
|
+
* a missing or stale CLAUDE.md block is drift either way. `syncClaude`
|
|
9477
|
+
* writes the same set of files whatever the value.
|
|
9478
|
+
*
|
|
9479
|
+
* A clone of such a project has no working hooks until it creates the
|
|
9480
|
+
* install: run the declared `sync_command` once after cloning. When
|
|
9481
|
+
* `settings.json` is one of the files kept out, Claude Code registers none of
|
|
9482
|
+
* these hooks before that sync, so the PreToolUse edit guard refuses no edit;
|
|
9483
|
+
* the CLAUDE.md block says so, naming the sync command.
|
|
9484
|
+
* The project manifest's `bindings.claude.local_hook_install` wins over it.
|
|
9485
|
+
*/
|
|
9486
|
+
local_hook_install: z3.boolean().default(false),
|
|
9440
9487
|
/** Override component id; defaults to `dsl.system.id`. */
|
|
9441
9488
|
component_id: z3.string().optional()
|
|
9442
9489
|
}).strip();
|
|
9443
9490
|
function parseClaudeConfig(raw) {
|
|
9444
9491
|
return ClaudeConfigSchema.parse(raw ?? {});
|
|
9445
9492
|
}
|
|
9446
|
-
function
|
|
9493
|
+
function harnessCommandsFor(config) {
|
|
9494
|
+
return { sync: config.sync_command, check: config.check_command };
|
|
9495
|
+
}
|
|
9496
|
+
function applyProjectBinding(config, project) {
|
|
9447
9497
|
if (!project) return config;
|
|
9448
9498
|
const emit = { ...config.emit };
|
|
9449
|
-
if (project.workflows !== void 0) emit.workflows = project.workflows;
|
|
9450
|
-
if (project.agents !== void 0) emit.agents = project.agents;
|
|
9451
|
-
if (project.harness !== void 0) emit.harness = project.harness;
|
|
9452
|
-
if (project.commands !== void 0) {
|
|
9453
|
-
emit.commands = project.commands ? config.emit.commands ?? {} : void 0;
|
|
9499
|
+
if (project.emit?.workflows !== void 0) emit.workflows = project.emit.workflows;
|
|
9500
|
+
if (project.emit?.agents !== void 0) emit.agents = project.emit.agents;
|
|
9501
|
+
if (project.emit?.harness !== void 0) emit.harness = project.emit.harness;
|
|
9502
|
+
if (project.emit?.commands !== void 0) {
|
|
9503
|
+
emit.commands = project.emit.commands ? config.emit.commands ?? {} : void 0;
|
|
9454
9504
|
}
|
|
9455
|
-
return {
|
|
9505
|
+
return {
|
|
9506
|
+
...config,
|
|
9507
|
+
emit,
|
|
9508
|
+
sync_command: project.sync_command ?? config.sync_command,
|
|
9509
|
+
check_command: project.check_command ?? config.check_command,
|
|
9510
|
+
local_hook_install: project.local_hook_install ?? config.local_hook_install
|
|
9511
|
+
};
|
|
9456
9512
|
}
|
|
9457
9513
|
|
|
9458
9514
|
// src/lib/claude-materialize/workflow-render.ts
|
|
9459
9515
|
import { resolveSchemaRefs } from "agent-contracts";
|
|
9460
|
-
import {
|
|
9516
|
+
import {
|
|
9517
|
+
claudeSyncReference,
|
|
9518
|
+
pathSegmentForId as pathSegmentForId4,
|
|
9519
|
+
readDslExtension
|
|
9520
|
+
} from "@aaac/contracts";
|
|
9461
9521
|
|
|
9462
9522
|
// src/lib/claude-materialize/dsl-sources.ts
|
|
9463
9523
|
import { existsSync as existsSync4 } from "fs";
|
|
@@ -9485,7 +9545,7 @@ async function resolveDslSources(root, embeddedDsl, config) {
|
|
|
9485
9545
|
embeddedDsl,
|
|
9486
9546
|
dslPath: config.config_path
|
|
9487
9547
|
});
|
|
9488
|
-
const dsl = await resolveNavigationDsl(navigationOptions);
|
|
9548
|
+
const { dsl } = await resolveNavigationDsl(navigationOptions);
|
|
9489
9549
|
return member === void 0 ? { dsl } : { member, dsl };
|
|
9490
9550
|
})
|
|
9491
9551
|
);
|
|
@@ -9510,7 +9570,9 @@ function mergeSourceFiles(rendered, conflict) {
|
|
|
9510
9570
|
}
|
|
9511
9571
|
|
|
9512
9572
|
// src/lib/claude-materialize/workflow-render.ts
|
|
9513
|
-
|
|
9573
|
+
function generatedMarker(commands) {
|
|
9574
|
+
return `// Auto-generated by @aaac/runtime claude-materialize (#235). Do not edit; regenerate with ${claudeSyncReference(commands)} instead.`;
|
|
9575
|
+
}
|
|
9514
9576
|
var CLAUDE_CODE_ADAPTER = "claude";
|
|
9515
9577
|
var WorkflowCodegenError = class extends Error {
|
|
9516
9578
|
constructor(message) {
|
|
@@ -9989,7 +10051,7 @@ function assertInScope(step) {
|
|
|
9989
10051
|
throw new WorkflowCodegenError(`Unknown workflow step type "${step.type}"`);
|
|
9990
10052
|
}
|
|
9991
10053
|
}
|
|
9992
|
-
function renderWorkflowScript(id, wf, dsl, modelMapping) {
|
|
10054
|
+
function renderWorkflowScript(id, wf, dsl, modelMapping, commands) {
|
|
9993
10055
|
const reg = buildRegistries(dsl, modelMapping);
|
|
9994
10056
|
const steps = wf.steps ?? [];
|
|
9995
10057
|
for (const step of steps) assertInScope(step);
|
|
@@ -10066,14 +10128,14 @@ function renderWorkflowScript(id, wf, dsl, modelMapping) {
|
|
|
10066
10128
|
body.push(" return { completed: true, workflow: " + jsString(id) + " }");
|
|
10067
10129
|
const metaLiteral = jsLiteral(meta, 0);
|
|
10068
10130
|
const topLevelBody = body.map((line) => line.startsWith(" ") ? line.slice(2) : line).join("\n");
|
|
10069
|
-
return `${
|
|
10131
|
+
return `${generatedMarker(commands)}
|
|
10070
10132
|
|
|
10071
10133
|
export const meta = ${metaLiteral}
|
|
10072
10134
|
|
|
10073
10135
|
${topLevelBody}
|
|
10074
10136
|
`;
|
|
10075
10137
|
}
|
|
10076
|
-
function renderWorkflowFiles(sources, outputDir, modelMapping) {
|
|
10138
|
+
function renderWorkflowFiles(sources, outputDir, modelMapping, commands) {
|
|
10077
10139
|
const dir = workflowsDirFor(outputDir);
|
|
10078
10140
|
return mergeSourceFiles(
|
|
10079
10141
|
sources.map((source) => ({
|
|
@@ -10082,7 +10144,7 @@ function renderWorkflowFiles(sources, outputDir, modelMapping) {
|
|
|
10082
10144
|
source.dsl.workflow ?? {}
|
|
10083
10145
|
).map(([id, wf]) => ({
|
|
10084
10146
|
path: `${dir}/${pathSegmentForId4("workflow id", id)}${WORKFLOW_FILE_EXT}`,
|
|
10085
|
-
content: renderWorkflowScript(id, wf, source.dsl, modelMapping)
|
|
10147
|
+
content: renderWorkflowScript(id, wf, source.dsl, modelMapping, commands)
|
|
10086
10148
|
}))
|
|
10087
10149
|
})),
|
|
10088
10150
|
(message) => new WorkflowCodegenError(message)
|
|
@@ -10178,7 +10240,7 @@ function renderCommandFiles(sources, outputTemplate, templateSource) {
|
|
|
10178
10240
|
}
|
|
10179
10241
|
|
|
10180
10242
|
// src/lib/claude-materialize/agent-render.ts
|
|
10181
|
-
import { pathSegmentForId as pathSegmentForId6 } from "@aaac/contracts";
|
|
10243
|
+
import { claudeSyncReference as claudeSyncReference2, pathSegmentForId as pathSegmentForId6 } from "@aaac/contracts";
|
|
10182
10244
|
var AgentCodegenError = class extends Error {
|
|
10183
10245
|
constructor(message) {
|
|
10184
10246
|
super(message);
|
|
@@ -10188,7 +10250,9 @@ var AgentCodegenError = class extends Error {
|
|
|
10188
10250
|
var AGENTS_SUBDIR = "agents";
|
|
10189
10251
|
var AGENT_FILE_EXT = ".md";
|
|
10190
10252
|
var AGENT_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
10191
|
-
|
|
10253
|
+
function generatedMarker2(commands) {
|
|
10254
|
+
return `<!-- Auto-generated from the agent-contracts DSL. Do not edit; regenerate with ${claudeSyncReference2(commands)}. -->`;
|
|
10255
|
+
}
|
|
10192
10256
|
function agentsDirFor(outputDir) {
|
|
10193
10257
|
return `${outputDir.replace(/\/+$/, "")}/${AGENTS_SUBDIR}`;
|
|
10194
10258
|
}
|
|
@@ -10233,7 +10297,7 @@ function agentDescription(agent) {
|
|
|
10233
10297
|
function renderAgentBody(agent) {
|
|
10234
10298
|
return [renderAgentSystemPrompt(agent), ...permissionSections(agent)].join("\n\n").replace(/\s+$/, "");
|
|
10235
10299
|
}
|
|
10236
|
-
function renderAgentFile(name, agent) {
|
|
10300
|
+
function renderAgentFile(name, agent, commands) {
|
|
10237
10301
|
const frontmatter = renderFrontmatter([
|
|
10238
10302
|
// `name` is validated against AGENT_NAME_PATTERN, so it is always a plain
|
|
10239
10303
|
// YAML scalar and needs no quoting. `description` is arbitrary DSL prose.
|
|
@@ -10242,7 +10306,7 @@ function renderAgentFile(name, agent) {
|
|
|
10242
10306
|
// The Claude Code tool grant follows the contract, never the DSL tool ids.
|
|
10243
10307
|
["tools", toolGrantForAgent(agent).join(", ")]
|
|
10244
10308
|
]);
|
|
10245
|
-
const body = [
|
|
10309
|
+
const body = [generatedMarker2(commands), renderAgentBody(agent)].join("\n\n");
|
|
10246
10310
|
return `${frontmatter}
|
|
10247
10311
|
${body}
|
|
10248
10312
|
`;
|
|
@@ -10270,7 +10334,7 @@ function mergeAgents(sources, dir) {
|
|
|
10270
10334
|
}
|
|
10271
10335
|
return merged;
|
|
10272
10336
|
}
|
|
10273
|
-
function renderAgentFiles(sources, outputDir) {
|
|
10337
|
+
function renderAgentFiles(sources, outputDir, commands) {
|
|
10274
10338
|
const dir = agentsDirFor(outputDir);
|
|
10275
10339
|
const files = [];
|
|
10276
10340
|
for (const [name, { agent, origin }] of mergeAgents(sources, dir)) {
|
|
@@ -10282,7 +10346,7 @@ function renderAgentFiles(sources, outputDir) {
|
|
|
10282
10346
|
}
|
|
10283
10347
|
files.push({
|
|
10284
10348
|
path: `${dir}/${pathSegmentForId6("agent id", name)}${AGENT_FILE_EXT}`,
|
|
10285
|
-
content: renderAgentFile(name, agent)
|
|
10349
|
+
content: renderAgentFile(name, agent, commands)
|
|
10286
10350
|
});
|
|
10287
10351
|
}
|
|
10288
10352
|
return files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
@@ -10306,6 +10370,7 @@ import {
|
|
|
10306
10370
|
|
|
10307
10371
|
// src/lib/claude-materialize/bundle-bins.ts
|
|
10308
10372
|
import {
|
|
10373
|
+
claudeSyncReference as claudeSyncReference3,
|
|
10309
10374
|
isHookBinChunk
|
|
10310
10375
|
} from "@aaac/contracts";
|
|
10311
10376
|
import { createHash } from "crypto";
|
|
@@ -10407,7 +10472,7 @@ function withMarker(bodyWithoutMarker) {
|
|
|
10407
10472
|
const firstNl = bodyWithoutMarker.indexOf("\n");
|
|
10408
10473
|
return bodyWithoutMarker.slice(0, firstNl + 1) + markerFor(bodyWithoutMarker) + "\n" + bodyWithoutMarker.slice(firstNl + 1);
|
|
10409
10474
|
}
|
|
10410
|
-
function assembleHookBin(source, kind) {
|
|
10475
|
+
function assembleHookBin(source, kind, commands) {
|
|
10411
10476
|
const withoutShebang = source.replace(/^#![^\n]*\n/, "");
|
|
10412
10477
|
const match = requireRuntimeImport(withoutShebang);
|
|
10413
10478
|
const binBody = withoutShebang.replace(
|
|
@@ -10417,21 +10482,21 @@ function assembleHookBin(source, kind) {
|
|
|
10417
10482
|
return withMarker(
|
|
10418
10483
|
[
|
|
10419
10484
|
"#!/usr/bin/env node",
|
|
10420
|
-
|
|
10485
|
+
`// Auto-generated by @aaac/runtime. Do not edit \u2014 self-contained bundle; regenerate with ${claudeSyncReference3(commands)}.`,
|
|
10421
10486
|
binBody.trimStart()
|
|
10422
10487
|
].join("\n")
|
|
10423
10488
|
);
|
|
10424
10489
|
}
|
|
10425
|
-
function assembleRuntimeChunk(kind) {
|
|
10490
|
+
function assembleRuntimeChunk(kind, commands) {
|
|
10426
10491
|
return withMarker(
|
|
10427
10492
|
[
|
|
10428
|
-
`// Auto-generated by @aaac/runtime
|
|
10493
|
+
`// Auto-generated by @aaac/runtime. Do not edit \u2014 shared ${kind} runtime chunk; regenerate with ${claudeSyncReference3(commands)}.`,
|
|
10429
10494
|
readPrebuiltBundle(kind).trimEnd(),
|
|
10430
10495
|
""
|
|
10431
10496
|
].join("\n")
|
|
10432
10497
|
);
|
|
10433
10498
|
}
|
|
10434
|
-
function withAssembledHookBins(files) {
|
|
10499
|
+
function withAssembledHookBins(files, commands) {
|
|
10435
10500
|
const out = [];
|
|
10436
10501
|
const needed = /* @__PURE__ */ new Set();
|
|
10437
10502
|
for (const file of files) {
|
|
@@ -10445,13 +10510,13 @@ function withAssembledHookBins(files) {
|
|
|
10445
10510
|
}
|
|
10446
10511
|
const kind = bundleKindFor(file.content);
|
|
10447
10512
|
needed.add(kind);
|
|
10448
|
-
out.push({ ...file, content: assembleHookBin(file.content, kind) });
|
|
10513
|
+
out.push({ ...file, content: assembleHookBin(file.content, kind, commands) });
|
|
10449
10514
|
}
|
|
10450
10515
|
for (const kind of BUNDLE_KINDS) {
|
|
10451
10516
|
if (!needed.has(kind)) continue;
|
|
10452
10517
|
out.push({
|
|
10453
10518
|
path: chunkFileName(kind),
|
|
10454
|
-
content: assembleRuntimeChunk(kind),
|
|
10519
|
+
content: assembleRuntimeChunk(kind, commands),
|
|
10455
10520
|
overwrite: true,
|
|
10456
10521
|
targetDir: HOOK_BIN_DIR
|
|
10457
10522
|
});
|
|
@@ -10617,11 +10682,12 @@ async function readIfExists(path) {
|
|
|
10617
10682
|
if (!existsSync5(path)) return void 0;
|
|
10618
10683
|
return readFile5(path, "utf8");
|
|
10619
10684
|
}
|
|
10620
|
-
async function renderFiles(root, dsl, config, entryAgentPrompt) {
|
|
10685
|
+
async function renderFiles(root, dsl, config, entryAgentPrompt, protectsArtifacts) {
|
|
10621
10686
|
if (!config.emit.harness) return [];
|
|
10622
10687
|
const ir = buildComponentIR(dsl, config);
|
|
10623
10688
|
const members = await workspaceMembersForProject(root);
|
|
10624
10689
|
const workspaceOptions = members.length > 0 ? { members } : void 0;
|
|
10690
|
+
const harnessCommands = harnessCommandsFor(config);
|
|
10625
10691
|
return withAssembledHookBins(
|
|
10626
10692
|
claudeGenerator.generate(ir, {
|
|
10627
10693
|
outputDir: "",
|
|
@@ -10634,8 +10700,14 @@ async function renderFiles(root, dsl, config, entryAgentPrompt) {
|
|
|
10634
10700
|
// subagent file, so the CLAUDE.md block is where its prompt reaches
|
|
10635
10701
|
// Claude (#345). Resolved by the caller from the SAME merge that produced
|
|
10636
10702
|
// the subagent files.
|
|
10637
|
-
entryAgentPrompt
|
|
10638
|
-
|
|
10703
|
+
entryAgentPrompt,
|
|
10704
|
+
harnessCommands,
|
|
10705
|
+
// Whether the block may say the edit guard protects anything.
|
|
10706
|
+
protectsArtifacts,
|
|
10707
|
+
// Whether the block must say a clone runs no hook until it is synced.
|
|
10708
|
+
localHookInstall: config.local_hook_install
|
|
10709
|
+
}),
|
|
10710
|
+
harnessCommands
|
|
10639
10711
|
);
|
|
10640
10712
|
}
|
|
10641
10713
|
function mergeClaudeMdBlock(existing, block) {
|
|
@@ -10671,8 +10743,11 @@ function actionForOverwriteTrue(existing, next) {
|
|
|
10671
10743
|
function isSettingsJson(file) {
|
|
10672
10744
|
return file.path === "settings.json" && file.targetDir === ".claude";
|
|
10673
10745
|
}
|
|
10746
|
+
function isClaudeMdBlock(file) {
|
|
10747
|
+
return file.path === "CLAUDE.md" && file.targetDir === "." && !file.overwrite;
|
|
10748
|
+
}
|
|
10674
10749
|
function resolveContent(file, existing) {
|
|
10675
|
-
if (file
|
|
10750
|
+
if (isClaudeMdBlock(file)) {
|
|
10676
10751
|
return mergeClaudeMdBlock(existing, file.content);
|
|
10677
10752
|
}
|
|
10678
10753
|
if (isSettingsJson(file)) {
|
|
@@ -10692,7 +10767,7 @@ function resolveContent(file, existing) {
|
|
|
10692
10767
|
return { content: file.content, action };
|
|
10693
10768
|
}
|
|
10694
10769
|
function checkContent(file, existing) {
|
|
10695
|
-
if (file
|
|
10770
|
+
if (isClaudeMdBlock(file)) {
|
|
10696
10771
|
if (existing === void 0) return "missing";
|
|
10697
10772
|
const expected = expectedClaudeMdContent(existing, file.content);
|
|
10698
10773
|
return existing === expected ? null : "changed";
|
|
@@ -10712,7 +10787,7 @@ function checkContent(file, existing) {
|
|
|
10712
10787
|
}
|
|
10713
10788
|
function workflowFiles(sources, config, modelMapping) {
|
|
10714
10789
|
if (!config.emit.workflows) return [];
|
|
10715
|
-
return renderWorkflowFiles(sources, config.output_dir, modelMapping);
|
|
10790
|
+
return renderWorkflowFiles(sources, config.output_dir, modelMapping, harnessCommandsFor(config));
|
|
10716
10791
|
}
|
|
10717
10792
|
function commandOutputTemplate(config) {
|
|
10718
10793
|
const commands = config.emit.commands;
|
|
@@ -10732,12 +10807,19 @@ async function commandFiles(sources, config, root) {
|
|
|
10732
10807
|
}
|
|
10733
10808
|
function agentFiles(sources, config) {
|
|
10734
10809
|
if (!config.emit.agents) return [];
|
|
10735
|
-
return renderAgentFiles(sources, config.output_dir);
|
|
10810
|
+
return renderAgentFiles(sources, config.output_dir, harnessCommandsFor(config));
|
|
10736
10811
|
}
|
|
10737
10812
|
function entryAgentPromptFor(sources, config) {
|
|
10738
10813
|
if (!config.emit.agents) return void 0;
|
|
10739
10814
|
return renderEntryAgentPrompt(sources, config.output_dir);
|
|
10740
10815
|
}
|
|
10816
|
+
function protectsAnyArtifact(sources) {
|
|
10817
|
+
return sources.some(
|
|
10818
|
+
(source) => Object.values(source.dsl.artifacts ?? {}).some(
|
|
10819
|
+
(artifact) => typeof artifact === "object" && artifact !== null && editProtection(artifact) !== void 0
|
|
10820
|
+
)
|
|
10821
|
+
);
|
|
10822
|
+
}
|
|
10741
10823
|
async function isOwnedHookBinFile(_name, absPath2) {
|
|
10742
10824
|
const content = await readIfExists(absPath2).catch(() => void 0);
|
|
10743
10825
|
return content !== void 0 && readBundleMarker(content) !== void 0;
|
|
@@ -10829,7 +10911,7 @@ function effectiveClaudeInputs(root, raw) {
|
|
|
10829
10911
|
if (!existsSync5(manifestPath)) return { config, modelMapping: {} };
|
|
10830
10912
|
const manifest = readProjectManifest(manifestPath);
|
|
10831
10913
|
return {
|
|
10832
|
-
config:
|
|
10914
|
+
config: applyProjectBinding(config, manifest.bindings?.claude),
|
|
10833
10915
|
modelMapping: manifest.model_mapping
|
|
10834
10916
|
};
|
|
10835
10917
|
}
|
|
@@ -10838,7 +10920,13 @@ async function syncClaude(opts) {
|
|
|
10838
10920
|
const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
|
|
10839
10921
|
const result = { files: [] };
|
|
10840
10922
|
const sources = await resolveDslSources(root, opts.dsl, config);
|
|
10841
|
-
const rendered = await renderFiles(
|
|
10923
|
+
const rendered = await renderFiles(
|
|
10924
|
+
root,
|
|
10925
|
+
opts.dsl,
|
|
10926
|
+
config,
|
|
10927
|
+
entryAgentPromptFor(sources, config),
|
|
10928
|
+
protectsAnyArtifact(sources)
|
|
10929
|
+
);
|
|
10842
10930
|
for (const file of rendered) {
|
|
10843
10931
|
const rel = generatedFileRelPath(file);
|
|
10844
10932
|
const abs = absPath(root, file);
|
|
@@ -10902,12 +10990,23 @@ async function checkClaude(opts) {
|
|
|
10902
10990
|
const root = resolve6(opts.projectRoot);
|
|
10903
10991
|
const { config, modelMapping } = effectiveClaudeInputs(root, opts.config);
|
|
10904
10992
|
const drift = [];
|
|
10993
|
+
const skipped = [];
|
|
10905
10994
|
const sources = await resolveDslSources(root, opts.dsl, config);
|
|
10906
|
-
const rendered = await renderFiles(
|
|
10995
|
+
const rendered = await renderFiles(
|
|
10996
|
+
root,
|
|
10997
|
+
opts.dsl,
|
|
10998
|
+
config,
|
|
10999
|
+
entryAgentPromptFor(sources, config),
|
|
11000
|
+
protectsAnyArtifact(sources)
|
|
11001
|
+
);
|
|
10907
11002
|
for (const file of rendered) {
|
|
10908
11003
|
const rel = generatedFileRelPath(file);
|
|
10909
11004
|
const abs = absPath(root, file);
|
|
10910
11005
|
const existing = await readIfExists(abs);
|
|
11006
|
+
if (existing === void 0 && config.local_hook_install && !isClaudeMdBlock(file)) {
|
|
11007
|
+
skipped.push(rel);
|
|
11008
|
+
continue;
|
|
11009
|
+
}
|
|
10911
11010
|
const contentReason = isHookBin(file.targetDir, file.path) ? checkHookBin(file, existing) : checkContent(file, existing);
|
|
10912
11011
|
const modeDrift = contentReason === null && file.executable === true && existing !== void 0 && await execBitMissing(abs);
|
|
10913
11012
|
const reason = contentReason ?? (modeDrift ? "changed" : null);
|
|
@@ -10930,7 +11029,7 @@ async function checkClaude(opts) {
|
|
|
10930
11029
|
for (const path of await orphanFiles(root, config, rendered, workflows, commands, agents)) {
|
|
10931
11030
|
drift.push({ path, reason: "orphaned" });
|
|
10932
11031
|
}
|
|
10933
|
-
return { inSync: drift.length === 0, drift };
|
|
11032
|
+
return { inSync: drift.length === 0, drift, skipped };
|
|
10934
11033
|
}
|
|
10935
11034
|
|
|
10936
11035
|
// src/lib/prompt-executor.ts
|