@leitwerk-dev/process-sdk 0.1.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/LICENSE +13 -0
- package/dist/browser-ui-extension.d.ts +27 -0
- package/dist/browser-ui-extension.d.ts.map +1 -0
- package/dist/browser-ui-extension.js +2 -0
- package/dist/browser-ui-extension.js.map +1 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +7 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chunk-5RJZ2E7D.js +58 -0
- package/dist/chunk-5RJZ2E7D.js.map +1 -0
- package/dist/chunk-ITPH65G6.js +197 -0
- package/dist/chunk-ITPH65G6.js.map +1 -0
- package/dist/chunk-LIIP7FMU.js +48 -0
- package/dist/chunk-LIIP7FMU.js.map +1 -0
- package/dist/codecs.d.ts +3 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +9 -0
- package/dist/codecs.js.map +1 -0
- package/dist/commit-message.d.ts +7 -0
- package/dist/commit-message.d.ts.map +1 -0
- package/dist/commit-message.js +3 -0
- package/dist/commit-message.js.map +1 -0
- package/dist/core-capabilities.d.ts +393 -0
- package/dist/core-capabilities.d.ts.map +1 -0
- package/dist/core-capabilities.js +6 -0
- package/dist/core-capabilities.js.map +1 -0
- package/dist/define-process.d.ts +269 -0
- package/dist/define-process.d.ts.map +1 -0
- package/dist/define-process.js +1040 -0
- package/dist/define-process.js.map +1 -0
- package/dist/event-bus.d.ts +3 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +31 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/extension-api-CnlL69Tu.d.ts +1281 -0
- package/dist/extension-api.d.ts +425 -0
- package/dist/extension-api.d.ts.map +1 -0
- package/dist/extension-api.js +5 -0
- package/dist/extension-api.js.map +1 -0
- package/dist/flow.d.ts +456 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +1557 -0
- package/dist/flow.js.map +1 -0
- package/dist/form-contract.d.ts +2 -0
- package/dist/form-contract.d.ts.map +1 -0
- package/dist/form-contract.js +2 -0
- package/dist/form-contract.js.map +1 -0
- package/dist/fs-utils.d.ts +3 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +23 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/git-binary.d.ts +11 -0
- package/dist/git-binary.d.ts.map +1 -0
- package/dist/git-binary.js +38 -0
- package/dist/git-binary.js.map +1 -0
- package/dist/graph-fragments.d.ts +23 -0
- package/dist/graph-fragments.d.ts.map +1 -0
- package/dist/graph-fragments.js +57 -0
- package/dist/graph-fragments.js.map +1 -0
- package/dist/host-capabilities.d.ts +12 -0
- package/dist/host-capabilities.d.ts.map +1 -0
- package/dist/host-capabilities.js +42 -0
- package/dist/host-capabilities.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher-contract.d.ts +2 -0
- package/dist/launcher-contract.d.ts.map +1 -0
- package/dist/launcher-contract.js +2 -0
- package/dist/launcher-contract.js.map +1 -0
- package/dist/leaf-outcome-renderer.d.ts +48 -0
- package/dist/leaf-outcome-renderer.d.ts.map +1 -0
- package/dist/leaf-outcome-renderer.js +69 -0
- package/dist/leaf-outcome-renderer.js.map +1 -0
- package/dist/leaf-outcomes.d.ts +5 -0
- package/dist/leaf-outcomes.d.ts.map +1 -0
- package/dist/leaf-outcomes.js +52 -0
- package/dist/leaf-outcomes.js.map +1 -0
- package/dist/model-provider.d.ts +210 -0
- package/dist/model-provider.d.ts.map +1 -0
- package/dist/model-provider.js +171 -0
- package/dist/model-provider.js.map +1 -0
- package/dist/pi-config.d.ts +59 -0
- package/dist/pi-config.d.ts.map +1 -0
- package/dist/pi-config.js +182 -0
- package/dist/pi-config.js.map +1 -0
- package/dist/process-definition-internals.d.ts +7 -0
- package/dist/process-definition-internals.d.ts.map +1 -0
- package/dist/process-definition-internals.js +25 -0
- package/dist/process-definition-internals.js.map +1 -0
- package/dist/process-flow-view.d.ts +20 -0
- package/dist/process-flow-view.d.ts.map +1 -0
- package/dist/process-flow-view.js +418 -0
- package/dist/process-flow-view.js.map +1 -0
- package/dist/process-graph.d.ts +45 -0
- package/dist/process-graph.d.ts.map +1 -0
- package/dist/process-graph.js +213 -0
- package/dist/process-graph.js.map +1 -0
- package/dist/process-launcher-builder.d.ts +9 -0
- package/dist/process-launcher-builder.d.ts.map +1 -0
- package/dist/process-launcher-builder.js +43 -0
- package/dist/process-launcher-builder.js.map +1 -0
- package/dist/process-watcher-builder.d.ts +10 -0
- package/dist/process-watcher-builder.d.ts.map +1 -0
- package/dist/process-watcher-builder.js +40 -0
- package/dist/process-watcher-builder.js.map +1 -0
- package/dist/registry-utils.d.ts +8 -0
- package/dist/registry-utils.d.ts.map +1 -0
- package/dist/registry-utils.js +18 -0
- package/dist/registry-utils.js.map +1 -0
- package/dist/repository-git-env.d.ts +8 -0
- package/dist/repository-git-env.d.ts.map +1 -0
- package/dist/repository-git-env.js +26 -0
- package/dist/repository-git-env.js.map +1 -0
- package/dist/review-flow.d.ts +10 -0
- package/dist/review-flow.d.ts.map +1 -0
- package/dist/review-flow.js +44 -0
- package/dist/review-flow.js.map +1 -0
- package/dist/runtime-internals.d.ts +3 -0
- package/dist/runtime-internals.d.ts.map +1 -0
- package/dist/runtime-internals.js +3 -0
- package/dist/runtime-internals.js.map +1 -0
- package/dist/server-events.d.ts +84 -0
- package/dist/server-events.d.ts.map +1 -0
- package/dist/server-events.js +2 -0
- package/dist/server-events.js.map +1 -0
- package/dist/server-process-builder.d.ts +11 -0
- package/dist/server-process-builder.d.ts.map +1 -0
- package/dist/server-process-builder.js +52 -0
- package/dist/server-process-builder.js.map +1 -0
- package/dist/state-helpers.d.ts +9 -0
- package/dist/state-helpers.d.ts.map +1 -0
- package/dist/state-helpers.js +20 -0
- package/dist/state-helpers.js.map +1 -0
- package/dist/subprocess-env.d.ts +12 -0
- package/dist/subprocess-env.d.ts.map +1 -0
- package/dist/subprocess-env.js +34 -0
- package/dist/subprocess-env.js.map +1 -0
- package/dist/tool-renderers.d.ts +10 -0
- package/dist/tool-renderers.d.ts.map +1 -0
- package/dist/tool-renderers.js +63 -0
- package/dist/tool-renderers.js.map +1 -0
- package/dist/turn-semantics.d.ts +22 -0
- package/dist/turn-semantics.d.ts.map +1 -0
- package/dist/turn-semantics.js +339 -0
- package/dist/turn-semantics.js.map +1 -0
- package/dist/types.d.ts +295 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/ui-process-builder.d.ts +9 -0
- package/dist/ui-process-builder.d.ts.map +1 -0
- package/dist/ui-process-builder.js +30 -0
- package/dist/ui-process-builder.js.map +1 -0
- package/dist/worker-process-builder.d.ts +10 -0
- package/dist/worker-process-builder.d.ts.map +1 -0
- package/dist/worker-process-builder.js +22 -0
- package/dist/worker-process-builder.js.map +1 -0
- package/package.json +72 -0
- package/src/browser-ui-extension.ts +32 -0
- package/src/capabilities.ts +16 -0
- package/src/codecs.ts +10 -0
- package/src/commit-message.ts +9 -0
- package/src/core-capabilities.ts +526 -0
- package/src/define-process.ts +1879 -0
- package/src/event-bus.ts +35 -0
- package/src/extension-api.ts +600 -0
- package/src/flow.ts +2268 -0
- package/src/form-contract.ts +11 -0
- package/src/fs-utils.ts +28 -0
- package/src/git-binary.ts +40 -0
- package/src/graph-fragments.ts +110 -0
- package/src/host-capabilities.ts +60 -0
- package/src/index.ts +468 -0
- package/src/launcher-contract.ts +8 -0
- package/src/leaf-outcome-renderer.ts +112 -0
- package/src/leaf-outcomes.ts +74 -0
- package/src/model-provider.ts +461 -0
- package/src/pi-config.ts +268 -0
- package/src/process-definition-internals.ts +46 -0
- package/src/process-flow-view.ts +479 -0
- package/src/process-graph.ts +309 -0
- package/src/process-launcher-builder.ts +59 -0
- package/src/process-watcher-builder.ts +72 -0
- package/src/registry-utils.ts +31 -0
- package/src/repository-git-env.ts +35 -0
- package/src/review-flow.ts +66 -0
- package/src/runtime-internals.ts +7 -0
- package/src/server-events.ts +105 -0
- package/src/server-process-builder.ts +90 -0
- package/src/state-helpers.ts +36 -0
- package/src/subprocess-env.ts +48 -0
- package/src/tool-renderers.ts +92 -0
- package/src/turn-semantics.ts +554 -0
- package/src/types.ts +391 -0
- package/src/ui-process-builder.ts +46 -0
- package/src/worker-process-builder.ts +33 -0
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Leitwerk contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WsFrame } from "@leitwerk-dev/protocol";
|
|
2
|
+
export interface BrowserUiExtensionContext {
|
|
3
|
+
readonly extensionManifestId: string;
|
|
4
|
+
readonly moduleUrl: string;
|
|
5
|
+
resolveAssetUrl(relativePath: string): string;
|
|
6
|
+
}
|
|
7
|
+
export interface BrowserUiShortcutRegistration {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly keys: readonly string[];
|
|
10
|
+
readonly label: string;
|
|
11
|
+
handle(event: KeyboardEvent): boolean | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface BrowserUiShellIndicatorRegistration {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
mount(host: HTMLElement): undefined | (() => void);
|
|
17
|
+
}
|
|
18
|
+
export type BrowserUiWsFrameHandler = (frame: WsFrame) => boolean | undefined;
|
|
19
|
+
export interface BrowserUiExtensionAPI {
|
|
20
|
+
registerShortcut(registration: BrowserUiShortcutRegistration): () => void;
|
|
21
|
+
registerShellIndicator(registration: BrowserUiShellIndicatorRegistration): () => void;
|
|
22
|
+
onWsFrame(handler: BrowserUiWsFrameHandler): () => void;
|
|
23
|
+
}
|
|
24
|
+
export interface BrowserUiExtensionModule {
|
|
25
|
+
setup(api: BrowserUiExtensionAPI, context: BrowserUiExtensionContext): void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=browser-ui-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-ui-extension.d.ts","sourceRoot":"","sources":["../src/browser-ui-extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9C;AAED,MAAM,WAAW,6BAA6B;IAC7C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;CAClD;AAED,MAAM,WAAW,mCAAmC;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,qBAAqB;IACrC,gBAAgB,CAAC,YAAY,EAAE,6BAA6B,GAAG,MAAM,IAAI,CAAC;IAC1E,sBAAsB,CAAC,YAAY,EAAE,mCAAmC,GAAG,MAAM,IAAI,CAAC;IACtF,SAAS,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAAC;CACxD;AAED,MAAM,WAAW,wBAAwB;IACxC,KAAK,CAAC,GAAG,EAAE,qBAAqB,EAAE,OAAO,EAAE,yBAAyB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-ui-extension.js","sourceRoot":"","sources":["../src/browser-ui-extension.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type CapabilityCardinality = "single" | "multi";
|
|
2
|
+
export interface CapabilityToken<_TValue> {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly cardinality: CapabilityCardinality;
|
|
5
|
+
}
|
|
6
|
+
export declare function createCapabilityToken<TValue>(id: string, options?: {
|
|
7
|
+
cardinality?: CapabilityCardinality;
|
|
8
|
+
}): CapabilityToken<TValue>;
|
|
9
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD,MAAM,WAAW,eAAe,CAAC,OAAO;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;CAC5C;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAC3C,EAAE,EAAE,MAAM,EACV,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,qBAAqB,CAAA;CAAO,GACnD,eAAe,CAAC,MAAM,CAAC,CAKzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,qBAAqB,CACpC,EAAU,EACV,UAAmD,EAAE;IAErD,OAAO;QACN,EAAE;QACF,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,QAAQ;KAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/process-definition-internals.ts
|
|
2
|
+
var registryKey = /* @__PURE__ */ Symbol.for("@leitwerk-dev/process-sdk/internal-registry");
|
|
3
|
+
var registryHolder = globalThis;
|
|
4
|
+
if (!registryHolder[registryKey]) {
|
|
5
|
+
registryHolder[registryKey] = {
|
|
6
|
+
definedProcesses: /* @__PURE__ */ new WeakSet(),
|
|
7
|
+
turnTransitions: /* @__PURE__ */ new WeakMap()
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
var registry = registryHolder[registryKey];
|
|
11
|
+
function markDefinedProcess(value) {
|
|
12
|
+
registry.definedProcesses.add(value);
|
|
13
|
+
}
|
|
14
|
+
function isDefinedProcess(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && registry.definedProcesses.has(value);
|
|
16
|
+
}
|
|
17
|
+
function setProcessTurnTransitions(binding, transitions) {
|
|
18
|
+
registry.turnTransitions.set(
|
|
19
|
+
binding,
|
|
20
|
+
transitions.map((transition) => ({ ...transition }))
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function getProcessTurnTransitions(binding) {
|
|
24
|
+
if (!binding) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return registry.turnTransitions.get(binding)?.map((transition) => ({ ...transition })) ?? [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/registry-utils.ts
|
|
31
|
+
function registerUnique(registry2, key, value, options) {
|
|
32
|
+
if (registry2.has(key)) {
|
|
33
|
+
throw new Error(options.duplicateMessage);
|
|
34
|
+
}
|
|
35
|
+
options.validate?.(value);
|
|
36
|
+
registry2.set(key, value);
|
|
37
|
+
}
|
|
38
|
+
function cloneMap(registry2) {
|
|
39
|
+
return new Map(registry2);
|
|
40
|
+
}
|
|
41
|
+
function cloneArrayValueMap(registry2) {
|
|
42
|
+
const cloned = /* @__PURE__ */ new Map();
|
|
43
|
+
for (const [key, values] of registry2) {
|
|
44
|
+
cloned.set(key, [...values]);
|
|
45
|
+
}
|
|
46
|
+
return cloned;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
markDefinedProcess,
|
|
51
|
+
isDefinedProcess,
|
|
52
|
+
setProcessTurnTransitions,
|
|
53
|
+
getProcessTurnTransitions,
|
|
54
|
+
registerUnique,
|
|
55
|
+
cloneMap,
|
|
56
|
+
cloneArrayValueMap
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=chunk-5RJZ2E7D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/process-definition-internals.ts","../src/registry-utils.ts"],"sourcesContent":["import type { ProcessTurnTransition } from \"@leitwerk-dev/domain\";\nimport type { ProcessTurnBinding } from \"./extension-api.js\";\n\ninterface ProcessDefinitionInternalRegistry {\n\tdefinedProcesses: WeakSet<object>;\n\tturnTransitions: WeakMap<object, readonly ProcessTurnTransition[]>;\n}\n\nconst registryKey = Symbol.for(\"@leitwerk-dev/process-sdk/internal-registry\");\nconst registryHolder = globalThis as typeof globalThis & {\n\t[registryKey]?: ProcessDefinitionInternalRegistry;\n};\nif (!registryHolder[registryKey]) {\n\tregistryHolder[registryKey] = {\n\t\tdefinedProcesses: new WeakSet<object>(),\n\t\tturnTransitions: new WeakMap<object, readonly ProcessTurnTransition[]>(),\n\t};\n}\nconst registry = registryHolder[registryKey];\n\nexport function markDefinedProcess(value: object): void {\n\tregistry.definedProcesses.add(value);\n}\n\nexport function isDefinedProcess(value: unknown): boolean {\n\treturn typeof value === \"object\" && value !== null && registry.definedProcesses.has(value);\n}\n\nexport function setProcessTurnTransitions(\n\tbinding: object,\n\ttransitions: readonly ProcessTurnTransition[],\n): void {\n\tregistry.turnTransitions.set(\n\t\tbinding,\n\t\ttransitions.map((transition) => ({ ...transition })),\n\t);\n}\n\nexport function getProcessTurnTransitions(\n\tbinding: ProcessTurnBinding<unknown> | undefined,\n): readonly ProcessTurnTransition[] {\n\tif (!binding) {\n\t\treturn [];\n\t}\n\treturn registry.turnTransitions.get(binding)?.map((transition) => ({ ...transition })) ?? [];\n}\n","export interface UniqueRegistrationOptions<TValue> {\n\tduplicateMessage: string;\n\tvalidate?: (value: TValue) => void;\n}\n\nexport function registerUnique<TKey, TValue>(\n\tregistry: Map<TKey, TValue>,\n\tkey: TKey,\n\tvalue: TValue,\n\toptions: UniqueRegistrationOptions<TValue>,\n): void {\n\tif (registry.has(key)) {\n\t\tthrow new Error(options.duplicateMessage);\n\t}\n\toptions.validate?.(value);\n\tregistry.set(key, value);\n}\n\nexport function cloneMap<TKey, TValue>(registry: ReadonlyMap<TKey, TValue>): Map<TKey, TValue> {\n\treturn new Map(registry);\n}\n\nexport function cloneArrayValueMap<TKey, TValue>(\n\tregistry: ReadonlyMap<TKey, readonly TValue[]>,\n): Map<TKey, readonly TValue[]> {\n\tconst cloned = new Map<TKey, readonly TValue[]>();\n\tfor (const [key, values] of registry) {\n\t\tcloned.set(key, [...values]);\n\t}\n\treturn cloned;\n}\n"],"mappings":";AAQA,IAAM,cAAc,uBAAO,IAAI,6CAA6C;AAC5E,IAAM,iBAAiB;AAGvB,IAAI,CAAC,eAAe,WAAW,GAAG;AACjC,iBAAe,WAAW,IAAI;AAAA,IAC7B,kBAAkB,oBAAI,QAAgB;AAAA,IACtC,iBAAiB,oBAAI,QAAkD;AAAA,EACxE;AACD;AACA,IAAM,WAAW,eAAe,WAAW;AAEpC,SAAS,mBAAmB,OAAqB;AACvD,WAAS,iBAAiB,IAAI,KAAK;AACpC;AAEO,SAAS,iBAAiB,OAAyB;AACzD,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,SAAS,iBAAiB,IAAI,KAAK;AAC1F;AAEO,SAAS,0BACf,SACA,aACO;AACP,WAAS,gBAAgB;AAAA,IACxB;AAAA,IACA,YAAY,IAAI,CAAC,gBAAgB,EAAE,GAAG,WAAW,EAAE;AAAA,EACpD;AACD;AAEO,SAAS,0BACf,SACmC;AACnC,MAAI,CAAC,SAAS;AACb,WAAO,CAAC;AAAA,EACT;AACA,SAAO,SAAS,gBAAgB,IAAI,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,WAAW,EAAE,KAAK,CAAC;AAC5F;;;ACxCO,SAAS,eACfA,WACA,KACA,OACA,SACO;AACP,MAAIA,UAAS,IAAI,GAAG,GAAG;AACtB,UAAM,IAAI,MAAM,QAAQ,gBAAgB;AAAA,EACzC;AACA,UAAQ,WAAW,KAAK;AACxB,EAAAA,UAAS,IAAI,KAAK,KAAK;AACxB;AAEO,SAAS,SAAuBA,WAAwD;AAC9F,SAAO,IAAI,IAAIA,SAAQ;AACxB;AAEO,SAAS,mBACfA,WAC+B;AAC/B,QAAM,SAAS,oBAAI,IAA6B;AAChD,aAAW,CAAC,KAAK,MAAM,KAAKA,WAAU;AACrC,WAAO,IAAI,KAAK,CAAC,GAAG,MAAM,CAAC;AAAA,EAC5B;AACA,SAAO;AACR;","names":["registry"]}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// src/pi-config.ts
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import Mustache from "mustache";
|
|
4
|
+
|
|
5
|
+
// src/types.ts
|
|
6
|
+
var PI_BUILT_IN_TOOL_NAMES = [
|
|
7
|
+
"read",
|
|
8
|
+
"bash",
|
|
9
|
+
"edit",
|
|
10
|
+
"write",
|
|
11
|
+
"grep",
|
|
12
|
+
"find",
|
|
13
|
+
"ls"
|
|
14
|
+
];
|
|
15
|
+
var TURN_CONTEXT_MODES = ["full", "compacted", "fresh", "fresh_seeded"];
|
|
16
|
+
var TURN_COMPLETION_MODES = ["turn_end"];
|
|
17
|
+
|
|
18
|
+
// src/pi-config.ts
|
|
19
|
+
function isScalarValue(value) {
|
|
20
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
21
|
+
}
|
|
22
|
+
function toTemplateContextRecord(value) {
|
|
23
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
const context = {};
|
|
27
|
+
for (const [key, candidate] of Object.entries(value)) {
|
|
28
|
+
if (isScalarValue(candidate)) {
|
|
29
|
+
context[key] = candidate;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
34
|
+
function createTemplateContext(input) {
|
|
35
|
+
const context = {
|
|
36
|
+
...toTemplateContextRecord(input.params)
|
|
37
|
+
};
|
|
38
|
+
if (input.process) {
|
|
39
|
+
context.processId = input.process.processId ?? void 0;
|
|
40
|
+
context.externalId = input.process.externalId ?? void 0;
|
|
41
|
+
context.externalUrl = input.process.externalUrl ?? void 0;
|
|
42
|
+
context.selectedTurnId = input.process.selectedTurnId ?? void 0;
|
|
43
|
+
}
|
|
44
|
+
const firstProject = input.projects?.[0];
|
|
45
|
+
if (firstProject) {
|
|
46
|
+
context.projectKey = firstProject.key;
|
|
47
|
+
context.repositoryUrl = firstProject.repoLocator;
|
|
48
|
+
context.baseBranch = firstProject.baseBranch;
|
|
49
|
+
context.workBranch = firstProject.workBranch ?? void 0;
|
|
50
|
+
}
|
|
51
|
+
return context;
|
|
52
|
+
}
|
|
53
|
+
function interpolateTemplate(template, context) {
|
|
54
|
+
return Mustache.render(template, context);
|
|
55
|
+
}
|
|
56
|
+
function isTurnDefinitionSource(source) {
|
|
57
|
+
return "kind" in source;
|
|
58
|
+
}
|
|
59
|
+
function resolveToolSourceDefinition(source) {
|
|
60
|
+
return isTurnDefinitionSource(source) ? source : source.definition;
|
|
61
|
+
}
|
|
62
|
+
function validatePiBuiltInToolArray(toolNames, context) {
|
|
63
|
+
const errors = [];
|
|
64
|
+
const seen = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const rawName of toolNames) {
|
|
66
|
+
if (typeof rawName !== "string") {
|
|
67
|
+
errors.push(`${context} must contain only string tool names`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const name = rawName.trim();
|
|
71
|
+
if (name === "") {
|
|
72
|
+
errors.push(`${context} must not contain empty tool names`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (name !== rawName) {
|
|
76
|
+
errors.push(`${context} must use canonical Pi tool names without surrounding whitespace`);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (!PI_BUILT_IN_TOOL_NAMES.includes(name)) {
|
|
80
|
+
errors.push(
|
|
81
|
+
`${context} references unknown Pi tool '${name}'. Expected one of ${PI_BUILT_IN_TOOL_NAMES.join(", ")}`
|
|
82
|
+
);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (seen.has(name)) {
|
|
86
|
+
errors.push(`${context} must not contain duplicate Pi tool '${name}'`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
seen.add(name);
|
|
90
|
+
}
|
|
91
|
+
return errors;
|
|
92
|
+
}
|
|
93
|
+
function resolveTurnAvailableToolNames(input) {
|
|
94
|
+
const errors = validatePiBuiltInToolArray(
|
|
95
|
+
input.turnDef.availableTools,
|
|
96
|
+
`turn '${input.turnId}' availableTools`
|
|
97
|
+
);
|
|
98
|
+
if (errors.length > 0) {
|
|
99
|
+
throw new Error(errors.join("; "));
|
|
100
|
+
}
|
|
101
|
+
return [...input.turnDef.availableTools];
|
|
102
|
+
}
|
|
103
|
+
function collectProcessAvailableToolNames(turns) {
|
|
104
|
+
const usedToolNames = /* @__PURE__ */ new Set();
|
|
105
|
+
for (const source of turns ?? []) {
|
|
106
|
+
const definition = resolveToolSourceDefinition(source);
|
|
107
|
+
if (definition.kind !== "llm" || !("availableTools" in definition)) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const errors = validatePiBuiltInToolArray(definition.availableTools, "LLM turn availableTools");
|
|
111
|
+
if (errors.length > 0) {
|
|
112
|
+
throw new Error(errors.join("; "));
|
|
113
|
+
}
|
|
114
|
+
for (const toolName of definition.availableTools) {
|
|
115
|
+
usedToolNames.add(toolName);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return PI_BUILT_IN_TOOL_NAMES.filter((toolName) => usedToolNames.has(toolName));
|
|
119
|
+
}
|
|
120
|
+
var DEFAULT_TOOL_DESCRIPTIONS = {
|
|
121
|
+
read: "Read file contents",
|
|
122
|
+
bash: "Execute bash commands (ls, grep, find, etc.)",
|
|
123
|
+
edit: "Make surgical edits to files (find exact text and replace)",
|
|
124
|
+
write: "Create or overwrite files",
|
|
125
|
+
grep: "Search file contents",
|
|
126
|
+
find: "Find files by name/path",
|
|
127
|
+
ls: "List directory contents"
|
|
128
|
+
};
|
|
129
|
+
function buildDefaultSystemPrompt(availableToolNames) {
|
|
130
|
+
const toolList = availableToolNames.length > 0 ? availableToolNames.map((toolName) => {
|
|
131
|
+
const description = DEFAULT_TOOL_DESCRIPTIONS[toolName] ?? "Built-in Pi tool";
|
|
132
|
+
return `- ${toolName}: ${description}`;
|
|
133
|
+
}).join("\n") : "- No built-in tools are available for this process unless a turn registers custom tools.";
|
|
134
|
+
return `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by using the tools made available for the active turn.
|
|
135
|
+
|
|
136
|
+
Available built-in tools for this process:
|
|
137
|
+
${toolList}
|
|
138
|
+
|
|
139
|
+
In addition to the tools above, you may have access to other custom tools depending on the active turn.
|
|
140
|
+
|
|
141
|
+
Guidelines:
|
|
142
|
+
- Use only tools that are available in the active turn.
|
|
143
|
+
- Use read/search tools to examine files before editing.
|
|
144
|
+
- Use edit for precise changes when it is available (old text must match exactly).
|
|
145
|
+
- Use write only for new files or complete rewrites when it is available.
|
|
146
|
+
- When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did.
|
|
147
|
+
- Be concise in your responses.
|
|
148
|
+
- Show file paths clearly when working with files.`;
|
|
149
|
+
}
|
|
150
|
+
function resolveProcessPiConfig(input) {
|
|
151
|
+
const processConfig = input.configSnapshot?.process_configs?.[input.processId];
|
|
152
|
+
const processPiOverride = processConfig?.pi;
|
|
153
|
+
const availableToolNames = collectProcessAvailableToolNames(input.turns);
|
|
154
|
+
const configSystemPromptTemplate = input.configSnapshot?.pi?.system_prompt_template;
|
|
155
|
+
const systemPromptTemplate = processPiOverride?.system_prompt_template ?? input.processPiConfig?.systemPromptTemplate ?? configSystemPromptTemplate;
|
|
156
|
+
const appendSystemPromptTemplate = processPiOverride?.append_system_prompt_template ?? input.processPiConfig?.appendSystemPromptTemplate;
|
|
157
|
+
const resolvedSystemPrompt = systemPromptTemplate ? interpolateTemplate(systemPromptTemplate, input.templateContext) : buildDefaultSystemPrompt(availableToolNames);
|
|
158
|
+
const sessionCwd = input.processPiConfig?.sessionCwdTemplate ? interpolateTemplate(input.processPiConfig.sessionCwdTemplate, input.templateContext).trim() : void 0;
|
|
159
|
+
return {
|
|
160
|
+
systemPrompt: resolvedSystemPrompt,
|
|
161
|
+
appendSystemPrompt: appendSystemPromptTemplate ? interpolateTemplate(appendSystemPromptTemplate, input.templateContext) : void 0,
|
|
162
|
+
...sessionCwd ? { sessionCwd } : {},
|
|
163
|
+
availableToolNames
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function resolveTurnActiveToolNames(input) {
|
|
167
|
+
return resolveTurnAvailableToolNames(input);
|
|
168
|
+
}
|
|
169
|
+
function expandPiAgentDir(agentDir) {
|
|
170
|
+
if (agentDir === "~") {
|
|
171
|
+
return homedir();
|
|
172
|
+
}
|
|
173
|
+
if (agentDir.startsWith("~/")) {
|
|
174
|
+
return homedir() + agentDir.slice(1);
|
|
175
|
+
}
|
|
176
|
+
return agentDir;
|
|
177
|
+
}
|
|
178
|
+
function resolvePiAgentDir(options) {
|
|
179
|
+
const configuredAgentDir = typeof options.agentDir === "string" && options.agentDir.trim() !== "" ? options.agentDir : typeof options.configSnapshot?.pi?.agent_dir === "string" && options.configSnapshot.pi.agent_dir.trim() !== "" ? options.configSnapshot.pi.agent_dir : options.fallbackDir;
|
|
180
|
+
return expandPiAgentDir(configuredAgentDir);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
PI_BUILT_IN_TOOL_NAMES,
|
|
185
|
+
TURN_CONTEXT_MODES,
|
|
186
|
+
TURN_COMPLETION_MODES,
|
|
187
|
+
createTemplateContext,
|
|
188
|
+
interpolateTemplate,
|
|
189
|
+
validatePiBuiltInToolArray,
|
|
190
|
+
resolveTurnAvailableToolNames,
|
|
191
|
+
collectProcessAvailableToolNames,
|
|
192
|
+
resolveProcessPiConfig,
|
|
193
|
+
resolveTurnActiveToolNames,
|
|
194
|
+
expandPiAgentDir,
|
|
195
|
+
resolvePiAgentDir
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=chunk-ITPH65G6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pi-config.ts","../src/types.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport type { ConfigSnapshot } from \"@leitwerk-dev/protocol\";\nimport Mustache from \"mustache\";\nimport type { LlmTurnDefinition } from \"./define-process.js\";\nimport {\n\tPI_BUILT_IN_TOOL_NAMES,\n\ttype PiBuiltInToolName,\n\ttype ProcessPiConfig,\n\ttype ResolvedProcessPiConfig,\n} from \"./types.js\";\n\ntype TemplateScalar = string | number | boolean;\ntype TemplateValue = TemplateScalar | TemplateContext | readonly TemplateValue[] | undefined;\n\nexport interface TemplateContext {\n\t[key: string]: TemplateValue;\n}\n\nfunction isScalarValue(value: unknown): value is string | number | boolean {\n\treturn typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\nfunction toTemplateContextRecord(value: unknown): TemplateContext {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\treturn {};\n\t}\n\tconst context: TemplateContext = {};\n\tfor (const [key, candidate] of Object.entries(value)) {\n\t\tif (isScalarValue(candidate)) {\n\t\t\tcontext[key] = candidate;\n\t\t}\n\t}\n\treturn context;\n}\n\nexport function createTemplateContext(input: {\n\tparams?: unknown;\n\tprocess?: {\n\t\tprocessId?: string | null;\n\t\texternalId?: string | null;\n\t\texternalUrl?: string | null;\n\t\tselectedTurnId?: string | null;\n\t};\n\tprojects?: ReadonlyArray<{\n\t\tkey: string;\n\t\trepoLocator: string;\n\t\tbaseBranch: string;\n\t\tworkBranch?: string | null;\n\t}>;\n}): TemplateContext {\n\tconst context: TemplateContext = {\n\t\t...toTemplateContextRecord(input.params),\n\t};\n\tif (input.process) {\n\t\tcontext.processId = input.process.processId ?? undefined;\n\t\tcontext.externalId = input.process.externalId ?? undefined;\n\t\tcontext.externalUrl = input.process.externalUrl ?? undefined;\n\t\tcontext.selectedTurnId = input.process.selectedTurnId ?? undefined;\n\t}\n\tconst firstProject = input.projects?.[0];\n\tif (firstProject) {\n\t\tcontext.projectKey = firstProject.key;\n\t\tcontext.repositoryUrl = firstProject.repoLocator;\n\t\tcontext.baseBranch = firstProject.baseBranch;\n\t\tcontext.workBranch = firstProject.workBranch ?? undefined;\n\t}\n\treturn context;\n}\n\nexport function interpolateTemplate(template: string, context: TemplateContext): string {\n\treturn Mustache.render(template, context);\n}\n\ntype TurnToolDefinitionLike =\n\t| { kind: \"llm\"; availableTools: readonly PiBuiltInToolName[] }\n\t| { kind: string };\n\ntype ProcessTurnBindingLike = {\n\tdefinition: TurnToolDefinitionLike;\n};\n\ntype ProcessToolSource = TurnToolDefinitionLike | ProcessTurnBindingLike;\n\nfunction isTurnDefinitionSource(source: ProcessToolSource): source is TurnToolDefinitionLike {\n\treturn \"kind\" in source;\n}\n\nfunction resolveToolSourceDefinition(source: ProcessToolSource): TurnToolDefinitionLike {\n\treturn isTurnDefinitionSource(source) ? source : source.definition;\n}\n\nexport function validatePiBuiltInToolArray(\n\ttoolNames: readonly unknown[],\n\tcontext: string,\n): string[] {\n\tconst errors: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const rawName of toolNames) {\n\t\tif (typeof rawName !== \"string\") {\n\t\t\terrors.push(`${context} must contain only string tool names`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst name = rawName.trim();\n\t\tif (name === \"\") {\n\t\t\terrors.push(`${context} must not contain empty tool names`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (name !== rawName) {\n\t\t\terrors.push(`${context} must use canonical Pi tool names without surrounding whitespace`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!PI_BUILT_IN_TOOL_NAMES.includes(name as PiBuiltInToolName)) {\n\t\t\terrors.push(\n\t\t\t\t`${context} references unknown Pi tool '${name}'. Expected one of ${PI_BUILT_IN_TOOL_NAMES.join(\", \")}`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tif (seen.has(name)) {\n\t\t\terrors.push(`${context} must not contain duplicate Pi tool '${name}'`);\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(name);\n\t}\n\treturn errors;\n}\n\nexport function resolveTurnAvailableToolNames(input: {\n\tturnId: string;\n\tturnDef: LlmTurnDefinition<string, unknown, unknown>;\n}): string[] {\n\tconst errors = validatePiBuiltInToolArray(\n\t\tinput.turnDef.availableTools,\n\t\t`turn '${input.turnId}' availableTools`,\n\t);\n\tif (errors.length > 0) {\n\t\tthrow new Error(errors.join(\"; \"));\n\t}\n\treturn [...input.turnDef.availableTools];\n}\n\nexport function collectProcessAvailableToolNames(\n\tturns: Iterable<ProcessToolSource> | undefined,\n): string[] {\n\tconst usedToolNames = new Set<PiBuiltInToolName>();\n\tfor (const source of turns ?? []) {\n\t\tconst definition = resolveToolSourceDefinition(source);\n\t\tif (definition.kind !== \"llm\" || !(\"availableTools\" in definition)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst errors = validatePiBuiltInToolArray(definition.availableTools, \"LLM turn availableTools\");\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(errors.join(\"; \"));\n\t\t}\n\t\tfor (const toolName of definition.availableTools) {\n\t\t\tusedToolNames.add(toolName);\n\t\t}\n\t}\n\treturn PI_BUILT_IN_TOOL_NAMES.filter((toolName) => usedToolNames.has(toolName));\n}\n\nconst DEFAULT_TOOL_DESCRIPTIONS: Record<PiBuiltInToolName, string> = {\n\tread: \"Read file contents\",\n\tbash: \"Execute bash commands (ls, grep, find, etc.)\",\n\tedit: \"Make surgical edits to files (find exact text and replace)\",\n\twrite: \"Create or overwrite files\",\n\tgrep: \"Search file contents\",\n\tfind: \"Find files by name/path\",\n\tls: \"List directory contents\",\n};\n\nfunction buildDefaultSystemPrompt(availableToolNames: readonly string[]): string {\n\tconst toolList =\n\t\tavailableToolNames.length > 0\n\t\t\t? availableToolNames\n\t\t\t\t\t.map((toolName) => {\n\t\t\t\t\t\tconst description =\n\t\t\t\t\t\t\tDEFAULT_TOOL_DESCRIPTIONS[toolName as PiBuiltInToolName] ?? \"Built-in Pi tool\";\n\t\t\t\t\t\treturn `- ${toolName}: ${description}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t: \"- No built-in tools are available for this process unless a turn registers custom tools.\";\n\treturn `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by using the tools made available for the active turn.\n\nAvailable built-in tools for this process:\n${toolList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the active turn.\n\nGuidelines:\n- Use only tools that are available in the active turn.\n- Use read/search tools to examine files before editing.\n- Use edit for precise changes when it is available (old text must match exactly).\n- Use write only for new files or complete rewrites when it is available.\n- When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did.\n- Be concise in your responses.\n- Show file paths clearly when working with files.`;\n}\n\nexport function resolveProcessPiConfig(input: {\n\tprocessId: string;\n\tprocessPiConfig?: ProcessPiConfig;\n\tturns?: Iterable<ProcessToolSource>;\n\tconfigSnapshot?: ConfigSnapshot;\n\ttemplateContext: TemplateContext;\n}): ResolvedProcessPiConfig {\n\tconst processConfig = input.configSnapshot?.process_configs?.[input.processId];\n\tconst processPiOverride = processConfig?.pi;\n\tconst availableToolNames = collectProcessAvailableToolNames(input.turns);\n\n\tconst configSystemPromptTemplate = input.configSnapshot?.pi?.system_prompt_template;\n\tconst systemPromptTemplate =\n\t\tprocessPiOverride?.system_prompt_template ??\n\t\tinput.processPiConfig?.systemPromptTemplate ??\n\t\tconfigSystemPromptTemplate;\n\tconst appendSystemPromptTemplate =\n\t\tprocessPiOverride?.append_system_prompt_template ??\n\t\tinput.processPiConfig?.appendSystemPromptTemplate;\n\n\tconst resolvedSystemPrompt = systemPromptTemplate\n\t\t? interpolateTemplate(systemPromptTemplate, input.templateContext)\n\t\t: buildDefaultSystemPrompt(availableToolNames);\n\tconst sessionCwd = input.processPiConfig?.sessionCwdTemplate\n\t\t? interpolateTemplate(input.processPiConfig.sessionCwdTemplate, input.templateContext).trim()\n\t\t: undefined;\n\n\treturn {\n\t\tsystemPrompt: resolvedSystemPrompt,\n\t\tappendSystemPrompt: appendSystemPromptTemplate\n\t\t\t? interpolateTemplate(appendSystemPromptTemplate, input.templateContext)\n\t\t\t: undefined,\n\t\t...(sessionCwd ? { sessionCwd } : {}),\n\t\tavailableToolNames,\n\t};\n}\n\nexport function resolveTurnActiveToolNames(input: {\n\tturnId: string;\n\tturnDef: LlmTurnDefinition<string, unknown, unknown>;\n}): string[] {\n\treturn resolveTurnAvailableToolNames(input);\n}\n\n// Mirror Pi's PI_CODING_AGENT_DIR expansion semantics from\n// pi-mono/packages/coding-agent/src/config.ts.\nexport function expandPiAgentDir(agentDir: string): string {\n\tif (agentDir === \"~\") {\n\t\treturn homedir();\n\t}\n\tif (agentDir.startsWith(\"~/\")) {\n\t\treturn homedir() + agentDir.slice(1);\n\t}\n\treturn agentDir;\n}\n\nexport function resolvePiAgentDir(options: {\n\tagentDir?: string | null;\n\tconfigSnapshot?: ConfigSnapshot;\n\tfallbackDir: string;\n}): string {\n\tconst configuredAgentDir =\n\t\ttypeof options.agentDir === \"string\" && options.agentDir.trim() !== \"\"\n\t\t\t? options.agentDir\n\t\t\t: typeof options.configSnapshot?.pi?.agent_dir === \"string\" &&\n\t\t\t\t\toptions.configSnapshot.pi.agent_dir.trim() !== \"\"\n\t\t\t\t? options.configSnapshot.pi.agent_dir\n\t\t\t\t: options.fallbackDir;\n\treturn expandPiAgentDir(configuredAgentDir);\n}\n","import type {\n\tProcessSemanticEntryRefKey as DomainProcessSemanticEntryRefKey,\n\tTurnAcceptanceState as DomainTurnAcceptanceState,\n\tProcessInstance,\n\tProcessProject,\n\tProcessTurnRecordPathType,\n\tProcessTurnTerminalLifecycleStatus,\n\tTurnId,\n} from \"@leitwerk-dev/domain\";\n\nexport interface ProcessContext {\n\treadonly process: ProcessInstance;\n\treadonly selectedTurnId: TurnId | null;\n\treadonly isTerminal: boolean;\n\treadonly projects: readonly ProcessProject[];\n\tselectTurn(turnId: TurnId | null): void;\n}\n\nexport interface TurnOptions {\n\treset?: boolean;\n}\n\nexport interface TurnResult<T extends string = string> {\n\toutcome: T;\n\tparams: Record<string, unknown>;\n}\n\nexport const PI_BUILT_IN_TOOL_NAMES = [\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n] as const;\nexport type PiBuiltInToolName = (typeof PI_BUILT_IN_TOOL_NAMES)[number];\n\nexport interface ProcessPiConfig {\n\t/**\n\t * System prompt template. Rendered with Mustache against runtime context.\n\t * Use {{variableName}} for escaped values and {{{variableName}}} for raw values.\n\t * When omitted, Pi's default system prompt is used.\n\t */\n\tsystemPromptTemplate?: string;\n\t/**\n\t * Additional text appended after the base system prompt/resources. Rendered\n\t * with Mustache against runtime context.\n\t */\n\tappendSystemPromptTemplate?: string;\n\t/**\n\t * Code-defined Pi session working directory template. Rendered with Mustache\n\t * against runtime context. When omitted, the process workspace root is used.\n\t */\n\tsessionCwdTemplate?: string;\n}\n\nexport interface ResolvedProcessPiConfig {\n\tsystemPrompt?: string;\n\tappendSystemPrompt?: string;\n\tsessionCwd?: string;\n\tavailableToolNames: string[];\n}\n\nexport type OutcomeToolParameterType = \"string\" | \"number\" | \"array\" | \"boolean\" | \"object\";\nexport type OutcomeToolArrayItemType = Exclude<OutcomeToolParameterType, \"array\">;\n\nexport interface OutcomeToolArrayItemSpec {\n\ttype: OutcomeToolArrayItemType;\n\tdescription?: string;\n}\n\nexport interface OutcomeToolParameterSpec {\n\ttype: OutcomeToolParameterType;\n\tdescription: string;\n\trequired?: boolean;\n\trequiredErrorCode?: string;\n\tinvalidErrorCode?: string;\n\tminItems?: number;\n\tminItemsErrorCode?: string;\n\tminimum?: number;\n\tminimumErrorCode?: string;\n\titems?: OutcomeToolArrayItemSpec;\n\tenum?: readonly string[];\n}\n\nexport interface OutcomeToolSpec {\n\tdescription: string;\n\tparameters: Record<string, OutcomeToolParameterSpec>;\n\t/** Product published from this outcome's turn-result markdown, when selected. */\n\tpublishedProduct?: string;\n\t/** Outcome parameter whose markdown value is captured as the turn result. */\n\tturnResultMarkdownParameter?: string;\n}\n\nexport interface ProcessToolResult {\n\tstatus: string;\n\toutcome?: string;\n}\n\nexport interface PiTreeEntry {\n\treadonly id: string;\n\treadonly parentId: string | null;\n\treadonly type: string;\n\treadonly timestamp: string;\n\treadonly message?: {\n\t\treadonly role?: string;\n\t\treadonly content?: unknown;\n\t};\n\t/** Pi custom-message fields. Details are intentionally excluded from model context. */\n\treadonly customType?: string;\n\treadonly content?: unknown;\n\treadonly details?: unknown;\n\treadonly targetId?: string;\n\treadonly label?: string;\n}\n\nexport interface PiTreeNode {\n\treadonly entry: PiTreeEntry;\n\treadonly children: readonly PiTreeNode[];\n\treadonly label?: string;\n\treadonly labelTimestamp?: string;\n}\n\nexport interface PiTurnExecutionResult {\n\tstartLeafId: string | null;\n\tendLeafId: string | null;\n\tcreatedEntryIds: string[];\n\tresultEntryId: string;\n\t/** Final assistant markdown captured from the Pi assistant message for this turn, when available. */\n\tassistantMarkdown?: string | null;\n}\n\nexport type PiEventType =\n\t| \"turn.start\"\n\t| \"turn.end\"\n\t| \"stream.delta\"\n\t| \"tool.call\"\n\t| \"tool.update\"\n\t| \"tool.result\"\n\t| \"toolcall.start\"\n\t| \"toolcall.delta\"\n\t| \"toolcall.end\"\n\t| \"compaction.start\"\n\t| \"compaction.end\"\n\t| \"label.changed\"\n\t| \"error\"\n\t| \"retry.start\"\n\t| \"retry.end\"\n\t| \"usage\";\n\nexport interface PiEvent {\n\ttype: PiEventType;\n\tturnId: string;\n\tdata: Record<string, unknown>;\n\ttimestamp: string;\n}\n\nexport type PiEventHandler = (event: PiEvent) => void;\n\nexport type PiSessionDiagnosticLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport interface PiSessionDiagnostic {\n\tlevel: PiSessionDiagnosticLevel;\n\tcode: string;\n\tmessage: string;\n\ttimestamp: string;\n\tturnId?: string;\n\tdetails?: Record<string, unknown>;\n}\n\nexport type PiSessionDiagnosticHandler = (diagnostic: PiSessionDiagnostic) => void;\n\nexport interface PiCustomToolExecutionContext {\n\t/** Pi's identity for this exact invocation; stable across the paused call. */\n\ttoolCallId: string;\n\t/** Aborted when the active turn is stopped or torn down. */\n\tsignal: AbortSignal;\n\t/** Pause model-execution budgets while this custom tool awaits durable operator input. */\n\tsuspendPromptGuards?: () => () => void;\n}\n\nexport interface PiCustomTool {\n\tname: string;\n\tdescription: string;\n\tparameters: Record<string, unknown>;\n\texecutionMode?: \"sequential\" | \"parallel\";\n\texecute(args: Record<string, unknown>, context?: PiCustomToolExecutionContext): Promise<unknown>;\n}\n\nexport interface PiUsageData {\n\tinput: number;\n\toutput: number;\n\t/** Provider-reported reasoning/thinking tokens. This is a subset of output tokens. */\n\treasoning?: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n\tcost: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\ttotal: number;\n\t};\n\tcacheHitRate: number;\n}\n\nexport interface PiRunDetails {\n\tloadedAgentsFiles: Array<{ path: string; sizeBytes: number }>;\n\tloadedSkills: Array<{ name: string; path: string }>;\n\tavailableToolNames: string[];\n}\n\nexport type ProcessCustomTool = PiCustomTool;\n\nexport interface PiCustomMessageInput {\n\tcontent: string;\n\tdetails: unknown;\n\tdisplay?: boolean;\n}\n\nexport type PiTerminalAcknowledgementState =\n\t| \"open\"\n\t| \"outcome_accepted\"\n\t| \"acknowledgement_succeeded\"\n\t| \"acknowledgement_failed_ignored\";\n\nexport interface PiTerminalAcknowledgementControl {\n\treadonly timeoutMs: number;\n\tstate(): PiTerminalAcknowledgementState;\n\tisOperatorAbortRequested(): boolean;\n\tmarkSucceeded(): void;\n\tmarkFailed(reason: string): void;\n}\n\nexport interface PiPromptOptions {\n\ttools?: readonly PiCustomTool[];\n\tactiveTools?: readonly string[];\n\t/** @internal Runtime-only hook used by the worker Pi adapter before a tool executes. */\n\tshouldBlockToolCall?: (toolName: string) => string | null;\n\t/** @internal Guard suspension used by durable interactive tools. */\n\tsuspendPromptGuards?: () => () => void;\n\t/** @internal Runtime-only terminal outcome acknowledgement state. */\n\tterminalAcknowledgement?: PiTerminalAcknowledgementControl;\n}\n\nexport interface PiTreeHandle {\n\treadonly sessionId: string;\n\treadonly treeFile: string;\n\treadonly isResumed: boolean;\n\n\tgetRunDetails(): PiRunDetails;\n\tgetLeafId(): string | null;\n\tgetEntry(id: string): PiTreeEntry | undefined;\n\tgetBranch(fromId?: string): PiTreeEntry[];\n\tgetChildren(parentId: string): PiTreeEntry[];\n\tgetTree(): PiTreeNode[];\n\tbranch(entryId: string): void | Promise<void>;\n\tbranchFromRoot(): void | Promise<void>;\n\tresetLeaf(): void | Promise<void>;\n\t/**\n\t * Compact the current Pi context. `details` is persisted with the resulting\n\t * compaction entry, but deliberately remains outside model context.\n\t */\n\tcompact?(customInstructions?: string, details?: unknown): Promise<unknown>;\n\tprompt(text: string, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;\n\tpromptLiteral(text: string, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;\n\tpromptCustom(\n\t\tinput: PiCustomMessageInput,\n\t\toptions?: PiPromptOptions,\n\t): Promise<PiTurnExecutionResult>;\n\tcontinueTurn(options?: PiPromptOptions): Promise<PiTurnExecutionResult>;\n\tappendCustomMessage?(input: PiCustomMessageInput): Promise<string>;\n\tsteer(text: string): Promise<void>;\n\tabortTurn(): Promise<void>;\n\tsubscribe(handler: PiEventHandler): () => void;\n\tsubscribeDiagnostics?(handler: PiSessionDiagnosticHandler): () => void;\n\tclose(): Promise<void>;\n}\n\nexport const TURN_CONTEXT_MODES = [\"full\", \"compacted\", \"fresh\", \"fresh_seeded\"] as const;\nexport type TurnContextMode = (typeof TURN_CONTEXT_MODES)[number];\n\nexport const TURN_COMPLETION_MODES = [\"turn_end\"] as const;\nexport type TurnCompletionMode = (typeof TURN_COMPLETION_MODES)[number];\n\nexport type TurnBranchType = ProcessTurnRecordPathType;\nexport type TurnSemanticEntryRefKey = DomainProcessSemanticEntryRefKey;\n\nexport interface TurnResultMarkdownNoneBehavior {\n\tmode: \"none\";\n}\n\nexport interface TurnResultMarkdownAssistantOutputBehavior {\n\tmode: \"assistant_output\";\n\trequired?: boolean;\n}\n\nexport interface TurnResultMarkdownToolCallBehavior {\n\tmode: \"tool_call\";\n\ttoolName: string;\n\tsource?: \"arguments\" | \"result\";\n\tpath: string;\n\trequired?: boolean;\n}\n\nexport interface TurnResultMarkdownOutcomeToolArgumentBehavior {\n\tmode: \"outcome_tool_argument\";\n\tparameterName: string;\n\trequired?: boolean;\n}\n\nexport type TurnResultMarkdownBehavior =\n\t| TurnResultMarkdownNoneBehavior\n\t| TurnResultMarkdownAssistantOutputBehavior\n\t| TurnResultMarkdownToolCallBehavior\n\t| TurnResultMarkdownOutcomeToolArgumentBehavior;\n\nexport type TurnAcceptanceState = DomainTurnAcceptanceState;\n\nexport interface ProcessActionSchedulingFixedTurnPreview {\n\tkind: \"fixed_turn\";\n\tturnId: TurnId | null;\n}\n\nexport interface ProcessActionSchedulingTriggerPreview {\n\tkind: \"trigger\";\n\ttrigger: string;\n}\n\nexport interface ProcessActionSchedulingTerminalPreview {\n\tkind: \"terminal\";\n\tlifecycleStatus: ProcessTurnTerminalLifecycleStatus;\n}\n\nexport type ProcessActionSchedulingPreview =\n\t| ProcessActionSchedulingFixedTurnPreview\n\t| ProcessActionSchedulingTriggerPreview\n\t| ProcessActionSchedulingTerminalPreview;\n\nexport type ProcessActionPreviewDefinition = ProcessActionSchedulingPreview;\n\nexport interface ProcessActionSchedulingDefinition {\n\tpreview: ProcessActionSchedulingPreview;\n}\n\nexport interface HumanTurnActionView {\n\tactionId: string;\n\tacceptanceState: TurnAcceptanceState;\n\tlabel?: string;\n\tdescription?: string;\n\tpreview?: ProcessActionPreviewDefinition;\n\tscheduling?: ProcessActionSchedulingDefinition;\n}\n\nexport interface HumanTurnNotesField {\n\tid: string;\n\tlabel: string;\n\tdescription?: string;\n\tplaceholder?: string;\n\trequired?: boolean;\n}\n\nexport interface HumanTurnExternalTrigger {\n\tid: string;\n\tactionId: string;\n\tlabel: string;\n\tdescription: string;\n}\n\nexport interface HumanTurnExternalActionView {\n\t/** Process-local arming id exposed to providers and UI. */\n\tid: string;\n\texternalActionId: string;\n\tsourceKind: string;\n\tlabel: string | null;\n\tdescription: string | null;\n}\n\nexport interface EventBus<TEventMap extends object = Record<string, unknown>> {\n\temit<K extends keyof TEventMap & string>(event: K, data: TEventMap[K]): void;\n\ton<K extends keyof TEventMap & string>(\n\t\tevent: K,\n\t\thandler: (data: TEventMap[K]) => void | Promise<void>,\n\t): void;\n\toff<K extends keyof TEventMap & string>(\n\t\tevent: K,\n\t\thandler: (data: TEventMap[K]) => void | Promise<void>,\n\t): void;\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,OAAO,cAAc;;;ACyBd,IAAM,yBAAyB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAsPO,IAAM,qBAAqB,CAAC,QAAQ,aAAa,SAAS,cAAc;AAGxE,IAAM,wBAAwB,CAAC,UAAU;;;AD1QhD,SAAS,cAAc,OAAoD;AAC1E,SAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU;AACnF;AAEA,SAAS,wBAAwB,OAAiC;AACjE,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG;AACxE,WAAO,CAAC;AAAA,EACT;AACA,QAAM,UAA2B,CAAC;AAClC,aAAW,CAAC,KAAK,SAAS,KAAK,OAAO,QAAQ,KAAK,GAAG;AACrD,QAAI,cAAc,SAAS,GAAG;AAC7B,cAAQ,GAAG,IAAI;AAAA,IAChB;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,sBAAsB,OAclB;AACnB,QAAM,UAA2B;AAAA,IAChC,GAAG,wBAAwB,MAAM,MAAM;AAAA,EACxC;AACA,MAAI,MAAM,SAAS;AAClB,YAAQ,YAAY,MAAM,QAAQ,aAAa;AAC/C,YAAQ,aAAa,MAAM,QAAQ,cAAc;AACjD,YAAQ,cAAc,MAAM,QAAQ,eAAe;AACnD,YAAQ,iBAAiB,MAAM,QAAQ,kBAAkB;AAAA,EAC1D;AACA,QAAM,eAAe,MAAM,WAAW,CAAC;AACvC,MAAI,cAAc;AACjB,YAAQ,aAAa,aAAa;AAClC,YAAQ,gBAAgB,aAAa;AACrC,YAAQ,aAAa,aAAa;AAClC,YAAQ,aAAa,aAAa,cAAc;AAAA,EACjD;AACA,SAAO;AACR;AAEO,SAAS,oBAAoB,UAAkB,SAAkC;AACvF,SAAO,SAAS,OAAO,UAAU,OAAO;AACzC;AAYA,SAAS,uBAAuB,QAA6D;AAC5F,SAAO,UAAU;AAClB;AAEA,SAAS,4BAA4B,QAAmD;AACvF,SAAO,uBAAuB,MAAM,IAAI,SAAS,OAAO;AACzD;AAEO,SAAS,2BACf,WACA,SACW;AACX,QAAM,SAAmB,CAAC;AAC1B,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,WAAW,WAAW;AAChC,QAAI,OAAO,YAAY,UAAU;AAChC,aAAO,KAAK,GAAG,OAAO,sCAAsC;AAC5D;AAAA,IACD;AACA,UAAM,OAAO,QAAQ,KAAK;AAC1B,QAAI,SAAS,IAAI;AAChB,aAAO,KAAK,GAAG,OAAO,oCAAoC;AAC1D;AAAA,IACD;AACA,QAAI,SAAS,SAAS;AACrB,aAAO,KAAK,GAAG,OAAO,kEAAkE;AACxF;AAAA,IACD;AACA,QAAI,CAAC,uBAAuB,SAAS,IAAyB,GAAG;AAChE,aAAO;AAAA,QACN,GAAG,OAAO,gCAAgC,IAAI,sBAAsB,uBAAuB,KAAK,IAAI,CAAC;AAAA,MACtG;AACA;AAAA,IACD;AACA,QAAI,KAAK,IAAI,IAAI,GAAG;AACnB,aAAO,KAAK,GAAG,OAAO,wCAAwC,IAAI,GAAG;AACrE;AAAA,IACD;AACA,SAAK,IAAI,IAAI;AAAA,EACd;AACA,SAAO;AACR;AAEO,SAAS,8BAA8B,OAGjC;AACZ,QAAM,SAAS;AAAA,IACd,MAAM,QAAQ;AAAA,IACd,SAAS,MAAM,MAAM;AAAA,EACtB;AACA,MAAI,OAAO,SAAS,GAAG;AACtB,UAAM,IAAI,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,EAClC;AACA,SAAO,CAAC,GAAG,MAAM,QAAQ,cAAc;AACxC;AAEO,SAAS,iCACf,OACW;AACX,QAAM,gBAAgB,oBAAI,IAAuB;AACjD,aAAW,UAAU,SAAS,CAAC,GAAG;AACjC,UAAM,aAAa,4BAA4B,MAAM;AACrD,QAAI,WAAW,SAAS,SAAS,EAAE,oBAAoB,aAAa;AACnE;AAAA,IACD;AACA,UAAM,SAAS,2BAA2B,WAAW,gBAAgB,yBAAyB;AAC9F,QAAI,OAAO,SAAS,GAAG;AACtB,YAAM,IAAI,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,IAClC;AACA,eAAW,YAAY,WAAW,gBAAgB;AACjD,oBAAc,IAAI,QAAQ;AAAA,IAC3B;AAAA,EACD;AACA,SAAO,uBAAuB,OAAO,CAAC,aAAa,cAAc,IAAI,QAAQ,CAAC;AAC/E;AAEA,IAAM,4BAA+D;AAAA,EACpE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AACL;AAEA,SAAS,yBAAyB,oBAA+C;AAChF,QAAM,WACL,mBAAmB,SAAS,IACzB,mBACC,IAAI,CAAC,aAAa;AAClB,UAAM,cACL,0BAA0B,QAA6B,KAAK;AAC7D,WAAO,KAAK,QAAQ,KAAK,WAAW;AAAA,EACrC,CAAC,EACA,KAAK,IAAI,IACV;AACJ,SAAO;AAAA;AAAA;AAAA,EAGN,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYV;AAEO,SAAS,uBAAuB,OAMX;AAC3B,QAAM,gBAAgB,MAAM,gBAAgB,kBAAkB,MAAM,SAAS;AAC7E,QAAM,oBAAoB,eAAe;AACzC,QAAM,qBAAqB,iCAAiC,MAAM,KAAK;AAEvE,QAAM,6BAA6B,MAAM,gBAAgB,IAAI;AAC7D,QAAM,uBACL,mBAAmB,0BACnB,MAAM,iBAAiB,wBACvB;AACD,QAAM,6BACL,mBAAmB,iCACnB,MAAM,iBAAiB;AAExB,QAAM,uBAAuB,uBAC1B,oBAAoB,sBAAsB,MAAM,eAAe,IAC/D,yBAAyB,kBAAkB;AAC9C,QAAM,aAAa,MAAM,iBAAiB,qBACvC,oBAAoB,MAAM,gBAAgB,oBAAoB,MAAM,eAAe,EAAE,KAAK,IAC1F;AAEH,SAAO;AAAA,IACN,cAAc;AAAA,IACd,oBAAoB,6BACjB,oBAAoB,4BAA4B,MAAM,eAAe,IACrE;AAAA,IACH,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;AAAA,IACnC;AAAA,EACD;AACD;AAEO,SAAS,2BAA2B,OAG9B;AACZ,SAAO,8BAA8B,KAAK;AAC3C;AAIO,SAAS,iBAAiB,UAA0B;AAC1D,MAAI,aAAa,KAAK;AACrB,WAAO,QAAQ;AAAA,EAChB;AACA,MAAI,SAAS,WAAW,IAAI,GAAG;AAC9B,WAAO,QAAQ,IAAI,SAAS,MAAM,CAAC;AAAA,EACpC;AACA,SAAO;AACR;AAEO,SAAS,kBAAkB,SAIvB;AACV,QAAM,qBACL,OAAO,QAAQ,aAAa,YAAY,QAAQ,SAAS,KAAK,MAAM,KACjE,QAAQ,WACR,OAAO,QAAQ,gBAAgB,IAAI,cAAc,YACjD,QAAQ,eAAe,GAAG,UAAU,KAAK,MAAM,KAC9C,QAAQ,eAAe,GAAG,YAC1B,QAAQ;AACb,SAAO,iBAAiB,kBAAkB;AAC3C;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/review-flow.ts
|
|
2
|
+
function filterStringArray(value) {
|
|
3
|
+
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
4
|
+
}
|
|
5
|
+
function normalizeMessage(value) {
|
|
6
|
+
return typeof value === "string" ? value : "";
|
|
7
|
+
}
|
|
8
|
+
function resolveOutcomeMarkdown(event, paramKey) {
|
|
9
|
+
if (typeof event.turnResultMarkdown === "string") {
|
|
10
|
+
return event.turnResultMarkdown;
|
|
11
|
+
}
|
|
12
|
+
const value = event.params[paramKey];
|
|
13
|
+
return typeof value === "string" ? value : void 0;
|
|
14
|
+
}
|
|
15
|
+
function buildPlanSavedEventPayload(input) {
|
|
16
|
+
return {
|
|
17
|
+
planRevision: input.planRevision,
|
|
18
|
+
summary: normalizeMessage(input.event.params.summary),
|
|
19
|
+
planMarkdown: resolveOutcomeMarkdown(input.event, "planMarkdown") ?? "",
|
|
20
|
+
acceptanceCriteria: filterStringArray(input.event.params.acceptanceCriteria)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function buildReviewRequestedEventPayload(event) {
|
|
24
|
+
return {
|
|
25
|
+
changedProjects: filterStringArray(event.params.changedProjects)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function buildReviewCompletedEventPayload(event) {
|
|
29
|
+
if (event.outcome === "issues_found") {
|
|
30
|
+
return {
|
|
31
|
+
hasIssues: true,
|
|
32
|
+
issueCount: typeof event.params.issueCount === "number" ? event.params.issueCount : 1,
|
|
33
|
+
...resolveOutcomeMarkdown(event, "reviewMarkdown") ? { reviewMarkdown: resolveOutcomeMarkdown(event, "reviewMarkdown") } : {}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
hasIssues: false,
|
|
38
|
+
issueCount: 0
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
filterStringArray,
|
|
44
|
+
buildPlanSavedEventPayload,
|
|
45
|
+
buildReviewRequestedEventPayload,
|
|
46
|
+
buildReviewCompletedEventPayload
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=chunk-LIIP7FMU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/review-flow.ts"],"sourcesContent":["import type { ProcessTurnOutcomeEvent } from \"./extension-api.js\";\nimport type {\n\tPlanSavedEvent,\n\tReviewCompletedEvent,\n\tReviewRequestedEvent,\n} from \"./server-events.js\";\n\nexport function filterStringArray(value: unknown): string[] {\n\treturn Array.isArray(value)\n\t\t? value.filter((entry): entry is string => typeof entry === \"string\")\n\t\t: [];\n}\n\nfunction normalizeMessage(value: unknown): string {\n\treturn typeof value === \"string\" ? value : \"\";\n}\n\nfunction resolveOutcomeMarkdown(\n\tevent: Pick<ProcessTurnOutcomeEvent, \"params\" | \"turnResultMarkdown\">,\n\tparamKey: string,\n): string | undefined {\n\tif (typeof event.turnResultMarkdown === \"string\") {\n\t\treturn event.turnResultMarkdown;\n\t}\n\tconst value = event.params[paramKey];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nexport function buildPlanSavedEventPayload(input: {\n\tplanRevision: number;\n\tevent: Pick<ProcessTurnOutcomeEvent, \"params\" | \"turnResultMarkdown\">;\n}): Omit<PlanSavedEvent, \"instanceId\"> {\n\treturn {\n\t\tplanRevision: input.planRevision,\n\t\tsummary: normalizeMessage(input.event.params.summary),\n\t\tplanMarkdown: resolveOutcomeMarkdown(input.event, \"planMarkdown\") ?? \"\",\n\t\tacceptanceCriteria: filterStringArray(input.event.params.acceptanceCriteria),\n\t};\n}\n\nexport function buildReviewRequestedEventPayload(\n\tevent: Pick<ProcessTurnOutcomeEvent, \"params\">,\n): Omit<ReviewRequestedEvent, \"instanceId\"> {\n\treturn {\n\t\tchangedProjects: filterStringArray(event.params.changedProjects),\n\t};\n}\n\nexport function buildReviewCompletedEventPayload(\n\tevent: Pick<ProcessTurnOutcomeEvent, \"outcome\" | \"params\" | \"turnResultMarkdown\">,\n): Omit<ReviewCompletedEvent, \"instanceId\"> {\n\tif (event.outcome === \"issues_found\") {\n\t\treturn {\n\t\t\thasIssues: true,\n\t\t\tissueCount: typeof event.params.issueCount === \"number\" ? event.params.issueCount : 1,\n\t\t\t...(resolveOutcomeMarkdown(event, \"reviewMarkdown\")\n\t\t\t\t? { reviewMarkdown: resolveOutcomeMarkdown(event, \"reviewMarkdown\") }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\treturn {\n\t\thasIssues: false,\n\t\tissueCount: 0,\n\t};\n}\n"],"mappings":";AAOO,SAAS,kBAAkB,OAA0B;AAC3D,SAAO,MAAM,QAAQ,KAAK,IACvB,MAAM,OAAO,CAAC,UAA2B,OAAO,UAAU,QAAQ,IAClE,CAAC;AACL;AAEA,SAAS,iBAAiB,OAAwB;AACjD,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC5C;AAEA,SAAS,uBACR,OACA,UACqB;AACrB,MAAI,OAAO,MAAM,uBAAuB,UAAU;AACjD,WAAO,MAAM;AAAA,EACd;AACA,QAAM,QAAQ,MAAM,OAAO,QAAQ;AACnC,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC5C;AAEO,SAAS,2BAA2B,OAGJ;AACtC,SAAO;AAAA,IACN,cAAc,MAAM;AAAA,IACpB,SAAS,iBAAiB,MAAM,MAAM,OAAO,OAAO;AAAA,IACpD,cAAc,uBAAuB,MAAM,OAAO,cAAc,KAAK;AAAA,IACrE,oBAAoB,kBAAkB,MAAM,MAAM,OAAO,kBAAkB;AAAA,EAC5E;AACD;AAEO,SAAS,iCACf,OAC2C;AAC3C,SAAO;AAAA,IACN,iBAAiB,kBAAkB,MAAM,OAAO,eAAe;AAAA,EAChE;AACD;AAEO,SAAS,iCACf,OAC2C;AAC3C,MAAI,MAAM,YAAY,gBAAgB;AACrC,WAAO;AAAA,MACN,WAAW;AAAA,MACX,YAAY,OAAO,MAAM,OAAO,eAAe,WAAW,MAAM,OAAO,aAAa;AAAA,MACpF,GAAI,uBAAuB,OAAO,gBAAgB,IAC/C,EAAE,gBAAgB,uBAAuB,OAAO,gBAAgB,EAAE,IAClE,CAAC;AAAA,IACL;AAAA,EACD;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,EACb;AACD;","names":[]}
|
package/dist/codecs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAOzD,CAAC"}
|
package/dist/codecs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../src/codecs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAiC;IAC7D,KAAK;QACJ,OAAO,EAAE,CAAC;IACX,CAAC;IACD,SAAS,CAAC,KAAK;QACd,OAAO,KAAK,CAAC;IACd,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const COMMIT_MESSAGE_PROJECT_METADATA_KEY = "leitwerk.commitMessage";
|
|
2
|
+
export declare const BUILT_IN_COMMIT_MESSAGE_RULES = "Write a concise imperative subject that summarizes the accepted plan. Add a body only when it provides useful context.";
|
|
3
|
+
export interface CommitMessageProjectMetadata {
|
|
4
|
+
templateId: string | null;
|
|
5
|
+
rules: string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=commit-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-message.d.ts","sourceRoot":"","sources":["../src/commit-message.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mCAAmC,2BAA2B,CAAC;AAE5E,eAAO,MAAM,6BAA6B,2HAC+E,CAAC;AAE1H,MAAM,WAAW,4BAA4B;IAC5C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export const COMMIT_MESSAGE_PROJECT_METADATA_KEY = "leitwerk.commitMessage";
|
|
2
|
+
export const BUILT_IN_COMMIT_MESSAGE_RULES = "Write a concise imperative subject that summarizes the accepted plan. Add a body only when it provides useful context.";
|
|
3
|
+
//# sourceMappingURL=commit-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-message.js","sourceRoot":"","sources":["../src/commit-message.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mCAAmC,GAAG,wBAAwB,CAAC;AAE5E,MAAM,CAAC,MAAM,6BAA6B,GACzC,wHAAwH,CAAC"}
|