poly-weaver 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +388 -0
- package/dist/agents/implementors/adapter.d.ts +18 -0
- package/dist/agents/implementors/adapter.d.ts.map +1 -0
- package/dist/agents/implementors/adapter.js +36 -0
- package/dist/agents/implementors/adapter.js.map +1 -0
- package/dist/agents/implementors/dsl.d.ts +11 -0
- package/dist/agents/implementors/dsl.d.ts.map +1 -0
- package/dist/agents/implementors/dsl.js +9 -0
- package/dist/agents/implementors/dsl.js.map +1 -0
- package/dist/agents/implementors/handler.d.ts +10 -0
- package/dist/agents/implementors/handler.d.ts.map +1 -0
- package/dist/agents/implementors/handler.js +55 -0
- package/dist/agents/implementors/handler.js.map +1 -0
- package/dist/agents/implementors/index.d.ts +10 -0
- package/dist/agents/implementors/index.d.ts.map +1 -0
- package/dist/agents/implementors/index.js +21 -0
- package/dist/agents/implementors/index.js.map +1 -0
- package/dist/agents/implementors/prompts.d.ts +20 -0
- package/dist/agents/implementors/prompts.d.ts.map +1 -0
- package/dist/agents/implementors/prompts.js +72 -0
- package/dist/agents/implementors/prompts.js.map +1 -0
- package/dist/agents/implementors/types.d.ts +24 -0
- package/dist/agents/implementors/types.d.ts.map +1 -0
- package/dist/agents/implementors/types.js +2 -0
- package/dist/agents/implementors/types.js.map +1 -0
- package/dist/agents/index.d.ts +12 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +25 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/planners/adapter.d.ts +22 -0
- package/dist/agents/planners/adapter.d.ts.map +1 -0
- package/dist/agents/planners/adapter.js +67 -0
- package/dist/agents/planners/adapter.js.map +1 -0
- package/dist/agents/planners/dsl.d.ts +13 -0
- package/dist/agents/planners/dsl.d.ts.map +1 -0
- package/dist/agents/planners/dsl.js +9 -0
- package/dist/agents/planners/dsl.js.map +1 -0
- package/dist/agents/planners/handler.d.ts +9 -0
- package/dist/agents/planners/handler.d.ts.map +1 -0
- package/dist/agents/planners/handler.js +86 -0
- package/dist/agents/planners/handler.js.map +1 -0
- package/dist/agents/planners/index.d.ts +10 -0
- package/dist/agents/planners/index.d.ts.map +1 -0
- package/dist/agents/planners/index.js +21 -0
- package/dist/agents/planners/index.js.map +1 -0
- package/dist/agents/planners/prompts.d.ts +30 -0
- package/dist/agents/planners/prompts.d.ts.map +1 -0
- package/dist/agents/planners/prompts.js +153 -0
- package/dist/agents/planners/prompts.js.map +1 -0
- package/dist/agents/planners/types.d.ts +37 -0
- package/dist/agents/planners/types.d.ts.map +1 -0
- package/dist/agents/planners/types.js +2 -0
- package/dist/agents/planners/types.js.map +1 -0
- package/dist/agents/registry.d.ts +29 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +44 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/reviewers/adapter.d.ts +10 -0
- package/dist/agents/reviewers/adapter.d.ts.map +1 -0
- package/dist/agents/reviewers/adapter.js +35 -0
- package/dist/agents/reviewers/adapter.js.map +1 -0
- package/dist/agents/reviewers/dsl.d.ts +12 -0
- package/dist/agents/reviewers/dsl.d.ts.map +1 -0
- package/dist/agents/reviewers/dsl.js +9 -0
- package/dist/agents/reviewers/dsl.js.map +1 -0
- package/dist/agents/reviewers/handler.d.ts +8 -0
- package/dist/agents/reviewers/handler.d.ts.map +1 -0
- package/dist/agents/reviewers/handler.js +48 -0
- package/dist/agents/reviewers/handler.js.map +1 -0
- package/dist/agents/reviewers/index.d.ts +10 -0
- package/dist/agents/reviewers/index.d.ts.map +1 -0
- package/dist/agents/reviewers/index.js +33 -0
- package/dist/agents/reviewers/index.js.map +1 -0
- package/dist/agents/reviewers/prompts.d.ts +25 -0
- package/dist/agents/reviewers/prompts.d.ts.map +1 -0
- package/dist/agents/reviewers/prompts.js +143 -0
- package/dist/agents/reviewers/prompts.js.map +1 -0
- package/dist/agents/reviewers/types.d.ts +35 -0
- package/dist/agents/reviewers/types.d.ts.map +1 -0
- package/dist/agents/reviewers/types.js +10 -0
- package/dist/agents/reviewers/types.js.map +1 -0
- package/dist/agents/runner.d.ts +62 -0
- package/dist/agents/runner.d.ts.map +1 -0
- package/dist/agents/runner.js +136 -0
- package/dist/agents/runner.js.map +1 -0
- package/dist/agents/simplifiers/adapter.d.ts +12 -0
- package/dist/agents/simplifiers/adapter.d.ts.map +1 -0
- package/dist/agents/simplifiers/adapter.js +27 -0
- package/dist/agents/simplifiers/adapter.js.map +1 -0
- package/dist/agents/simplifiers/dsl.d.ts +11 -0
- package/dist/agents/simplifiers/dsl.d.ts.map +1 -0
- package/dist/agents/simplifiers/dsl.js +9 -0
- package/dist/agents/simplifiers/dsl.js.map +1 -0
- package/dist/agents/simplifiers/handler.d.ts +9 -0
- package/dist/agents/simplifiers/handler.d.ts.map +1 -0
- package/dist/agents/simplifiers/handler.js +39 -0
- package/dist/agents/simplifiers/handler.js.map +1 -0
- package/dist/agents/simplifiers/index.d.ts +10 -0
- package/dist/agents/simplifiers/index.d.ts.map +1 -0
- package/dist/agents/simplifiers/index.js +20 -0
- package/dist/agents/simplifiers/index.js.map +1 -0
- package/dist/agents/simplifiers/prompts.d.ts +11 -0
- package/dist/agents/simplifiers/prompts.d.ts.map +1 -0
- package/dist/agents/simplifiers/prompts.js +24 -0
- package/dist/agents/simplifiers/prompts.js.map +1 -0
- package/dist/agents/simplifiers/types.d.ts +15 -0
- package/dist/agents/simplifiers/types.d.ts.map +1 -0
- package/dist/agents/simplifiers/types.js +2 -0
- package/dist/agents/simplifiers/types.js.map +1 -0
- package/dist/agents/whip-hint.d.ts +23 -0
- package/dist/agents/whip-hint.d.ts.map +1 -0
- package/dist/agents/whip-hint.js +41 -0
- package/dist/agents/whip-hint.js.map +1 -0
- package/dist/ansi.d.ts +39 -0
- package/dist/ansi.d.ts.map +1 -0
- package/dist/ansi.js +158 -0
- package/dist/ansi.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +309 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +55 -0
- package/dist/config.js.map +1 -0
- package/dist/dsl.d.ts +25 -0
- package/dist/dsl.d.ts.map +1 -0
- package/dist/dsl.js +16 -0
- package/dist/dsl.js.map +1 -0
- package/dist/flow/artifacts.d.ts +13 -0
- package/dist/flow/artifacts.d.ts.map +1 -0
- package/dist/flow/artifacts.js +27 -0
- package/dist/flow/artifacts.js.map +1 -0
- package/dist/flow/built-in/default.d.ts +15 -0
- package/dist/flow/built-in/default.d.ts.map +1 -0
- package/dist/flow/built-in/default.js +123 -0
- package/dist/flow/built-in/default.js.map +1 -0
- package/dist/flow/built-in/default.ts +152 -0
- package/dist/flow/built-in/why-so-serious.d.ts +15 -0
- package/dist/flow/built-in/why-so-serious.d.ts.map +1 -0
- package/dist/flow/built-in/why-so-serious.js +147 -0
- package/dist/flow/built-in/why-so-serious.js.map +1 -0
- package/dist/flow/custom/AUTHORING.md +558 -0
- package/dist/flow/custom/index.d.ts +3 -0
- package/dist/flow/custom/index.d.ts.map +1 -0
- package/dist/flow/custom/index.js +2 -0
- package/dist/flow/custom/index.js.map +1 -0
- package/dist/flow/custom/load.d.ts +19 -0
- package/dist/flow/custom/load.d.ts.map +1 -0
- package/dist/flow/custom/load.js +117 -0
- package/dist/flow/custom/load.js.map +1 -0
- package/dist/flow/diagram.d.ts +37 -0
- package/dist/flow/diagram.d.ts.map +1 -0
- package/dist/flow/diagram.js +596 -0
- package/dist/flow/diagram.js.map +1 -0
- package/dist/flow/dsl.d.ts +65 -0
- package/dist/flow/dsl.d.ts.map +1 -0
- package/dist/flow/dsl.js +210 -0
- package/dist/flow/dsl.js.map +1 -0
- package/dist/flow/executor.d.ts +22 -0
- package/dist/flow/executor.d.ts.map +1 -0
- package/dist/flow/executor.js +185 -0
- package/dist/flow/executor.js.map +1 -0
- package/dist/flow/index.d.ts +16 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +12 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/inspect.d.ts +21 -0
- package/dist/flow/inspect.d.ts.map +1 -0
- package/dist/flow/inspect.js +54 -0
- package/dist/flow/inspect.js.map +1 -0
- package/dist/flow/neighbors.d.ts +10 -0
- package/dist/flow/neighbors.d.ts.map +1 -0
- package/dist/flow/neighbors.js +48 -0
- package/dist/flow/neighbors.js.map +1 -0
- package/dist/flow/params.d.ts +21 -0
- package/dist/flow/params.d.ts.map +1 -0
- package/dist/flow/params.js +44 -0
- package/dist/flow/params.js.map +1 -0
- package/dist/flow/types.d.ts +159 -0
- package/dist/flow/types.d.ts.map +1 -0
- package/dist/flow/types.js +33 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/flow-editor/index.d.ts +9 -0
- package/dist/flow-editor/index.d.ts.map +1 -0
- package/dist/flow-editor/index.js +6 -0
- package/dist/flow-editor/index.js.map +1 -0
- package/dist/flow-editor/llm.d.ts +33 -0
- package/dist/flow-editor/llm.d.ts.map +1 -0
- package/dist/flow-editor/llm.js +137 -0
- package/dist/flow-editor/llm.js.map +1 -0
- package/dist/flow-editor/names.d.ts +5 -0
- package/dist/flow-editor/names.d.ts.map +1 -0
- package/dist/flow-editor/names.js +21 -0
- package/dist/flow-editor/names.js.map +1 -0
- package/dist/flow-editor/save.d.ts +59 -0
- package/dist/flow-editor/save.d.ts.map +1 -0
- package/dist/flow-editor/save.js +143 -0
- package/dist/flow-editor/save.js.map +1 -0
- package/dist/flow-editor/tui.d.ts +56 -0
- package/dist/flow-editor/tui.d.ts.map +1 -0
- package/dist/flow-editor/tui.js +628 -0
- package/dist/flow-editor/tui.js.map +1 -0
- package/dist/flow-editor/validate.d.ts +39 -0
- package/dist/flow-editor/validate.d.ts.map +1 -0
- package/dist/flow-editor/validate.js +192 -0
- package/dist/flow-editor/validate.js.map +1 -0
- package/dist/git-info.d.ts +6 -0
- package/dist/git-info.d.ts.map +1 -0
- package/dist/git-info.js +26 -0
- package/dist/git-info.js.map +1 -0
- package/dist/orchestrator.d.ts +55 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +240 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/preflight.d.ts +30 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +107 -0
- package/dist/preflight.js.map +1 -0
- package/dist/preview-panel.d.ts +87 -0
- package/dist/preview-panel.d.ts.map +1 -0
- package/dist/preview-panel.js +418 -0
- package/dist/preview-panel.js.map +1 -0
- package/dist/prompts.d.ts +34 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +67 -0
- package/dist/prompts.js.map +1 -0
- package/dist/providers/base-completion.d.ts +56 -0
- package/dist/providers/base-completion.d.ts.map +1 -0
- package/dist/providers/base-completion.js +111 -0
- package/dist/providers/base-completion.js.map +1 -0
- package/dist/providers/claude/completion.d.ts +28 -0
- package/dist/providers/claude/completion.d.ts.map +1 -0
- package/dist/providers/claude/completion.js +103 -0
- package/dist/providers/claude/completion.js.map +1 -0
- package/dist/providers/claude/index.d.ts +2 -0
- package/dist/providers/claude/index.d.ts.map +1 -0
- package/dist/providers/claude/index.js +2 -0
- package/dist/providers/claude/index.js.map +1 -0
- package/dist/providers/claude/session.d.ts +55 -0
- package/dist/providers/claude/session.d.ts.map +1 -0
- package/dist/providers/claude/session.js +172 -0
- package/dist/providers/claude/session.js.map +1 -0
- package/dist/providers/claude/strategy.d.ts +14 -0
- package/dist/providers/claude/strategy.d.ts.map +1 -0
- package/dist/providers/claude/strategy.js +38 -0
- package/dist/providers/claude/strategy.js.map +1 -0
- package/dist/providers/codex/completion.d.ts +21 -0
- package/dist/providers/codex/completion.d.ts.map +1 -0
- package/dist/providers/codex/completion.js +63 -0
- package/dist/providers/codex/completion.js.map +1 -0
- package/dist/providers/codex/index.d.ts +2 -0
- package/dist/providers/codex/index.d.ts.map +1 -0
- package/dist/providers/codex/index.js +2 -0
- package/dist/providers/codex/index.js.map +1 -0
- package/dist/providers/codex/session.d.ts +46 -0
- package/dist/providers/codex/session.d.ts.map +1 -0
- package/dist/providers/codex/session.js +151 -0
- package/dist/providers/codex/session.js.map +1 -0
- package/dist/providers/codex/strategy.d.ts +14 -0
- package/dist/providers/codex/strategy.d.ts.map +1 -0
- package/dist/providers/codex/strategy.js +41 -0
- package/dist/providers/codex/strategy.js.map +1 -0
- package/dist/providers/copilot/completion.d.ts +22 -0
- package/dist/providers/copilot/completion.d.ts.map +1 -0
- package/dist/providers/copilot/completion.js +65 -0
- package/dist/providers/copilot/completion.js.map +1 -0
- package/dist/providers/copilot/index.d.ts +2 -0
- package/dist/providers/copilot/index.d.ts.map +1 -0
- package/dist/providers/copilot/index.js +2 -0
- package/dist/providers/copilot/index.js.map +1 -0
- package/dist/providers/copilot/session.d.ts +39 -0
- package/dist/providers/copilot/session.d.ts.map +1 -0
- package/dist/providers/copilot/session.js +185 -0
- package/dist/providers/copilot/session.js.map +1 -0
- package/dist/providers/copilot/strategy.d.ts +14 -0
- package/dist/providers/copilot/strategy.d.ts.map +1 -0
- package/dist/providers/copilot/strategy.js +48 -0
- package/dist/providers/copilot/strategy.js.map +1 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +6 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/invoke.d.ts +14 -0
- package/dist/providers/invoke.d.ts.map +1 -0
- package/dist/providers/invoke.js +55 -0
- package/dist/providers/invoke.js.map +1 -0
- package/dist/providers/path-utils.d.ts +7 -0
- package/dist/providers/path-utils.d.ts.map +1 -0
- package/dist/providers/path-utils.js +9 -0
- package/dist/providers/path-utils.js.map +1 -0
- package/dist/providers/prompt-file.d.ts +8 -0
- package/dist/providers/prompt-file.d.ts.map +1 -0
- package/dist/providers/prompt-file.js +17 -0
- package/dist/providers/prompt-file.js.map +1 -0
- package/dist/providers/registry.d.ts +17 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +49 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/types.d.ts +145 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +5 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/version.d.ts +11 -0
- package/dist/providers/version.d.ts.map +1 -0
- package/dist/providers/version.js +31 -0
- package/dist/providers/version.js.map +1 -0
- package/dist/pty/exit.d.ts +12 -0
- package/dist/pty/exit.d.ts.map +1 -0
- package/dist/pty/exit.js +43 -0
- package/dist/pty/exit.js.map +1 -0
- package/dist/pty/spawn.d.ts +20 -0
- package/dist/pty/spawn.d.ts.map +1 -0
- package/dist/pty/spawn.js +163 -0
- package/dist/pty/spawn.js.map +1 -0
- package/dist/pty/types.d.ts +44 -0
- package/dist/pty/types.d.ts.map +1 -0
- package/dist/pty/types.js +2 -0
- package/dist/pty/types.js.map +1 -0
- package/dist/session/dir.d.ts +19 -0
- package/dist/session/dir.d.ts.map +1 -0
- package/dist/session/dir.js +31 -0
- package/dist/session/dir.js.map +1 -0
- package/dist/session/locator.d.ts +28 -0
- package/dist/session/locator.d.ts.map +1 -0
- package/dist/session/locator.js +88 -0
- package/dist/session/locator.js.map +1 -0
- package/dist/session/reader.d.ts +12 -0
- package/dist/session/reader.d.ts.map +1 -0
- package/dist/session/reader.js +94 -0
- package/dist/session/reader.js.map +1 -0
- package/dist/startup-tui.d.ts +75 -0
- package/dist/startup-tui.d.ts.map +1 -0
- package/dist/startup-tui.js +504 -0
- package/dist/startup-tui.js.map +1 -0
- package/dist/status-bar.d.ts +29 -0
- package/dist/status-bar.d.ts.map +1 -0
- package/dist/status-bar.js +135 -0
- package/dist/status-bar.js.map +1 -0
- package/dist/terminal-input.d.ts +51 -0
- package/dist/terminal-input.d.ts.map +1 -0
- package/dist/terminal-input.js +212 -0
- package/dist/terminal-input.js.map +1 -0
- package/dist/user/dsl.d.ts +13 -0
- package/dist/user/dsl.d.ts.map +1 -0
- package/dist/user/dsl.js +19 -0
- package/dist/user/dsl.js.map +1 -0
- package/dist/user/handler.d.ts +16 -0
- package/dist/user/handler.d.ts.map +1 -0
- package/dist/user/handler.js +49 -0
- package/dist/user/handler.js.map +1 -0
- package/dist/user/index.d.ts +5 -0
- package/dist/user/index.d.ts.map +1 -0
- package/dist/user/index.js +4 -0
- package/dist/user/index.js.map +1 -0
- package/dist/user/prompt.d.ts +86 -0
- package/dist/user/prompt.d.ts.map +1 -0
- package/dist/user/prompt.js +320 -0
- package/dist/user/prompt.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +50 -0
- package/schemas/review-verdict.json +41 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude: invoke built-in /simplify skill.
|
|
3
|
+
* /simplify = "Review changed code for reuse, quality, and efficiency, then fix any issues found."
|
|
4
|
+
*/
|
|
5
|
+
export function claudeSimplifierPrompt(outputPlanFile) {
|
|
6
|
+
return [
|
|
7
|
+
"/simplify",
|
|
8
|
+
"",
|
|
9
|
+
`Write your complete plan markdown to this file: ${outputPlanFile}`,
|
|
10
|
+
].join("\n");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Codex & Copilot: explicit textual equivalent of Claude's /simplify skill.
|
|
14
|
+
* These providers have no built-in simplify command, so we spell out the task.
|
|
15
|
+
*/
|
|
16
|
+
export function defaultSimplifierPrompt(outputPlanFile) {
|
|
17
|
+
return [
|
|
18
|
+
"Review the changed code in the working directory for code reuse, quality, and efficiency.",
|
|
19
|
+
"Identify any issues and propose fixes for each one.",
|
|
20
|
+
"",
|
|
21
|
+
`Write your complete plan markdown to this file: ${outputPlanFile}`,
|
|
22
|
+
].join("\n");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/agents/simplifiers/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,cAAsB;IAC3D,OAAO;QACL,WAAW;QACX,EAAE;QACF,mDAAmD,cAAc,EAAE;KACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,cAAsB;IAC5D,OAAO;QACL,2FAA2F;QAC3F,qDAAqD;QACrD,EAAE;QACF,mDAAmD,cAAc,EAAE;KACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type SimplifierPromptFn = (outputPlanFile: string) => string;
|
|
2
|
+
export interface SimplifierDriver {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
run(opts: {
|
|
5
|
+
outputPlanFile: string;
|
|
6
|
+
resumeSessionId?: string;
|
|
7
|
+
}): Promise<SimplifierResult>;
|
|
8
|
+
getSessionId(): string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type SimplifierResult = {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
rawText?: string;
|
|
13
|
+
agentUsed: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agents/simplifiers/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC3F,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/agents/simplifiers/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StepMeta } from "../flow/types.js";
|
|
2
|
+
/** Message formatters for whip-mode hints. */
|
|
3
|
+
export interface WhipHintMessages {
|
|
4
|
+
producer: (names: string) => string;
|
|
5
|
+
consumer: (names: string) => string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Collect external neighbor display names (different driver from self),
|
|
9
|
+
* then format them using the provided message templates.
|
|
10
|
+
*
|
|
11
|
+
* Returns undefined when there is nothing to say (all neighbors use the
|
|
12
|
+
* same driver, or no neighbors are provided).
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildWhipHint(selfDriver: string, opts: {
|
|
15
|
+
producers?: Record<string, StepMeta>;
|
|
16
|
+
consumers?: Record<string, StepMeta[]>;
|
|
17
|
+
}, messages: WhipHintMessages): string | undefined;
|
|
18
|
+
/** Default messages for producer roles (planner, implementor). */
|
|
19
|
+
export declare function buildAgentWhipHint(selfDriver: string, opts: {
|
|
20
|
+
producers?: Record<string, StepMeta>;
|
|
21
|
+
consumers?: Record<string, StepMeta[]>;
|
|
22
|
+
}, artifactNoun: string): string | undefined;
|
|
23
|
+
//# sourceMappingURL=whip-hint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whip-hint.d.ts","sourceRoot":"","sources":["../../src/agents/whip-hint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;CAAE,EACtF,QAAQ,EAAE,gBAAgB,GACzB,MAAM,GAAG,SAAS,CA0BpB;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;CAAE,EACtF,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAKpB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect external neighbor display names (different driver from self),
|
|
3
|
+
* then format them using the provided message templates.
|
|
4
|
+
*
|
|
5
|
+
* Returns undefined when there is nothing to say (all neighbors use the
|
|
6
|
+
* same driver, or no neighbors are provided).
|
|
7
|
+
*/
|
|
8
|
+
export function buildWhipHint(selfDriver, opts, messages) {
|
|
9
|
+
const parts = [];
|
|
10
|
+
if (opts.producers) {
|
|
11
|
+
const names = new Set();
|
|
12
|
+
for (const meta of Object.values(opts.producers)) {
|
|
13
|
+
if (meta.driver !== selfDriver)
|
|
14
|
+
names.add(meta.displayName);
|
|
15
|
+
}
|
|
16
|
+
if (names.size > 0) {
|
|
17
|
+
parts.push(messages.producer([...names].join(", ")));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (opts.consumers) {
|
|
21
|
+
const names = new Set();
|
|
22
|
+
for (const metas of Object.values(opts.consumers)) {
|
|
23
|
+
for (const meta of metas) {
|
|
24
|
+
if (meta.driver !== selfDriver)
|
|
25
|
+
names.add(meta.displayName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (names.size > 0) {
|
|
29
|
+
parts.push(messages.consumer([...names].join(", ")));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return parts.length > 0 ? parts.join(" ") : undefined;
|
|
33
|
+
}
|
|
34
|
+
/** Default messages for producer roles (planner, implementor). */
|
|
35
|
+
export function buildAgentWhipHint(selfDriver, opts, artifactNoun) {
|
|
36
|
+
return buildWhipHint(selfDriver, opts, {
|
|
37
|
+
producer: (names) => `The previous step was performed by ${names}.`,
|
|
38
|
+
consumer: (names) => `${names} will review your ${artifactNoun}.`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=whip-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whip-hint.js","sourceRoot":"","sources":["../../src/agents/whip-hint.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,UAAkB,EAClB,IAAsF,EACtF,QAA0B;IAE1B,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;QAChC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACjD,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU;gBAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAA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
|
4
|
+
* Strips ANSI escape sequences, then iterates code points:
|
|
5
|
+
* - Surrogate-pair emoji (cp > 0xFFFF): width 2
|
|
6
|
+
* - BMP emoji with Emoji_Presentation=Yes: width 2
|
|
7
|
+
* - VS16 (U+FE0F): width 0 (presentation selector, adds no column)
|
|
8
|
+
* - Everything else: width 1
|
|
9
|
+
*/
|
|
10
|
+
export declare function visibleLength(s: string): number;
|
|
11
|
+
export declare const dim = "\u001B[2m";
|
|
12
|
+
export declare const bold = "\u001B[1m";
|
|
13
|
+
export declare const reset = "\u001B[0m";
|
|
14
|
+
export declare const cyan = "\u001B[36m";
|
|
15
|
+
export declare const green = "\u001B[32m";
|
|
16
|
+
export declare const yellow = "\u001B[33m";
|
|
17
|
+
export declare const clearToEol = "\u001B[K";
|
|
18
|
+
export declare const cursorUp = "\u001B[A";
|
|
19
|
+
/** Reset scroll region to full terminal height. */
|
|
20
|
+
export declare const RESET_SCROLL_REGION = "\u001B[r";
|
|
21
|
+
/** Clear entire visible screen. */
|
|
22
|
+
export declare const CLEAR_SCREEN = "\u001B[2J";
|
|
23
|
+
/** Move cursor to row 1, column 1. */
|
|
24
|
+
export declare const CURSOR_HOME = "\u001B[H";
|
|
25
|
+
/** Show cursor (undo DECTCEM hide). */
|
|
26
|
+
export declare const SHOW_CURSOR = "\u001B[?25h";
|
|
27
|
+
/** Hide cursor (DECTCEM). */
|
|
28
|
+
export declare const HIDE_CURSOR = "\u001B[?25l";
|
|
29
|
+
/** Switch to alternate screen buffer. */
|
|
30
|
+
export declare const ALT_SCREEN_ON = "\u001B[?1049h";
|
|
31
|
+
/** Leave alternate screen buffer. */
|
|
32
|
+
export declare const ALT_SCREEN_OFF = "\u001B[?1049l";
|
|
33
|
+
export declare const red = "\u001B[31m";
|
|
34
|
+
export declare const invert = "\u001B[7m";
|
|
35
|
+
/** CSI (Control Sequence Introducer) prefix for ANSI escape sequences. */
|
|
36
|
+
export declare const CSI = "\u001B[";
|
|
37
|
+
/** Pad a line with spaces to reach exactly `width` visible characters. */
|
|
38
|
+
export declare function padToWidth(line: string, width: number): string;
|
|
39
|
+
//# sourceMappingURL=ansi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.d.ts","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,QAAoB,CAAC;AAmGzC;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAa/C;AAED,eAAO,MAAM,GAAG,cAAY,CAAC;AAC7B,eAAO,MAAM,IAAI,cAAY,CAAC;AAC9B,eAAO,MAAM,KAAK,cAAY,CAAC;AAC/B,eAAO,MAAM,IAAI,eAAa,CAAC;AAC/B,eAAO,MAAM,KAAK,eAAa,CAAC;AAChC,eAAO,MAAM,MAAM,eAAa,CAAC;AACjC,eAAO,MAAM,UAAU,aAAW,CAAC;AACnC,eAAO,MAAM,QAAQ,aAAW,CAAC;AAEjC,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,aAAW,CAAC;AAC5C,mCAAmC;AACnC,eAAO,MAAM,YAAY,cAAY,CAAC;AACtC,sCAAsC;AACtC,eAAO,MAAM,WAAW,aAAW,CAAC;AACpC,uCAAuC;AACvC,eAAO,MAAM,WAAW,gBAAc,CAAC;AACvC,6BAA6B;AAC7B,eAAO,MAAM,WAAW,gBAAc,CAAC;AACvC,yCAAyC;AACzC,eAAO,MAAM,aAAa,kBAAgB,CAAC;AAC3C,qCAAqC;AACrC,eAAO,MAAM,cAAc,kBAAgB,CAAC;AAE5C,eAAO,MAAM,GAAG,eAAa,CAAC;AAC9B,eAAO,MAAM,MAAM,cAAY,CAAC;AAEhC,0EAA0E;AAC1E,eAAO,MAAM,GAAG,YAAU,CAAC;AAE3B,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9D"}
|
package/dist/ansi.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// eslint-disable-next-line no-control-regex
|
|
2
|
+
export const ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
3
|
+
/**
|
|
4
|
+
* BMP code points with Emoji_Presentation=Yes (Unicode 15.1).
|
|
5
|
+
* These render as wide (2-column) glyphs in terminals despite being
|
|
6
|
+
* single JS code units (`.length` = 1). Sorted ranges for binary search.
|
|
7
|
+
*/
|
|
8
|
+
const WIDE_BMP_EMOJI = [
|
|
9
|
+
[0x231A, 0x231B], // ⌚⌛
|
|
10
|
+
[0x23E9, 0x23F3], // ⏩–⏳
|
|
11
|
+
[0x23F8, 0x23FA], // ⏸–⏺
|
|
12
|
+
[0x25AA, 0x25AB], // ▪▫
|
|
13
|
+
[0x25B6, 0x25B6], // ▶
|
|
14
|
+
[0x25C0, 0x25C0], // ◀
|
|
15
|
+
[0x25FB, 0x25FE], // ◻–◾
|
|
16
|
+
[0x2600, 0x2604], // ☀–☄
|
|
17
|
+
[0x260E, 0x260E], // ☎
|
|
18
|
+
[0x2611, 0x2611], // ☑
|
|
19
|
+
[0x2614, 0x2615], // ☔☕
|
|
20
|
+
[0x2618, 0x2618], // ☘
|
|
21
|
+
[0x261D, 0x261D], // ☝
|
|
22
|
+
[0x2620, 0x2620], // ☠
|
|
23
|
+
[0x2622, 0x2623], // ☢☣
|
|
24
|
+
[0x2626, 0x2626], // ☦
|
|
25
|
+
[0x262A, 0x262A], // ☪
|
|
26
|
+
[0x262E, 0x262F], // ☮☯
|
|
27
|
+
[0x2638, 0x263A], // ☸–☺
|
|
28
|
+
[0x2640, 0x2640], // ♀
|
|
29
|
+
[0x2642, 0x2642], // ♂
|
|
30
|
+
[0x2648, 0x2653], // ♈–♓
|
|
31
|
+
[0x265F, 0x2660], // ♟♠
|
|
32
|
+
[0x2663, 0x2663], // ♣
|
|
33
|
+
[0x2665, 0x2666], // ♥♦
|
|
34
|
+
[0x2668, 0x2668], // ♨
|
|
35
|
+
[0x267B, 0x267B], // ♻
|
|
36
|
+
[0x267E, 0x267F], // ♾♿
|
|
37
|
+
[0x2692, 0x2697], // ⚒–⚗
|
|
38
|
+
[0x2699, 0x2699], // ⚙
|
|
39
|
+
[0x269B, 0x269C], // ⚛⚜
|
|
40
|
+
[0x26A0, 0x26A1], // ⚠⚡
|
|
41
|
+
[0x26A7, 0x26A7], // ⚧
|
|
42
|
+
[0x26AA, 0x26AB], // ⚪⚫
|
|
43
|
+
[0x26B0, 0x26B1], // ⚰⚱
|
|
44
|
+
[0x26BD, 0x26BE], // ⚽⚾
|
|
45
|
+
[0x26C4, 0x26C5], // ⛄⛅
|
|
46
|
+
[0x26C8, 0x26C8], // ⛈
|
|
47
|
+
[0x26CE, 0x26CF], // ⛎⛏
|
|
48
|
+
[0x26D1, 0x26D1], // ⛑
|
|
49
|
+
[0x26D3, 0x26D4], // ⛓⛔
|
|
50
|
+
[0x26E9, 0x26EA], // ⛩⛪
|
|
51
|
+
[0x26F0, 0x26F5], // ⛰–⛵
|
|
52
|
+
[0x26F7, 0x26FA], // ⛷–⛺
|
|
53
|
+
[0x26FD, 0x26FD], // ⛽
|
|
54
|
+
[0x2702, 0x2702], // ✂
|
|
55
|
+
[0x2705, 0x2705], // ✅
|
|
56
|
+
[0x2708, 0x270D], // ✈–✍
|
|
57
|
+
[0x270F, 0x270F], // ✏
|
|
58
|
+
[0x2712, 0x2712], // ✒
|
|
59
|
+
[0x2714, 0x2714], // ✔
|
|
60
|
+
[0x2716, 0x2716], // ✖
|
|
61
|
+
[0x271D, 0x271D], // ✝
|
|
62
|
+
[0x2721, 0x2721], // ✡
|
|
63
|
+
[0x2728, 0x2728], // ✨
|
|
64
|
+
[0x2733, 0x2734], // ✳✴
|
|
65
|
+
[0x2744, 0x2744], // ❄
|
|
66
|
+
[0x2747, 0x2747], // ❇
|
|
67
|
+
[0x274C, 0x274C], // ❌
|
|
68
|
+
[0x274E, 0x274E], // ❎
|
|
69
|
+
[0x2753, 0x2755], // ❓–❕
|
|
70
|
+
[0x2757, 0x2757], // ❗
|
|
71
|
+
[0x2763, 0x2764], // ❣❤
|
|
72
|
+
[0x2795, 0x2797], // ➕–➗
|
|
73
|
+
[0x27A1, 0x27A1], // ➡
|
|
74
|
+
[0x27B0, 0x27B0], // ➰
|
|
75
|
+
[0x27BF, 0x27BF], // ➿
|
|
76
|
+
[0x2934, 0x2935], // ⤴⤵
|
|
77
|
+
[0x2B05, 0x2B07], // ⬅–⬇
|
|
78
|
+
[0x2B1B, 0x2B1C], // ⬛⬜
|
|
79
|
+
[0x2B50, 0x2B50], // ⭐
|
|
80
|
+
[0x2B55, 0x2B55], // ⭕
|
|
81
|
+
[0x3030, 0x3030], // 〰
|
|
82
|
+
[0x303D, 0x303D], // 〽
|
|
83
|
+
[0x3297, 0x3297], // ㊗
|
|
84
|
+
[0x3299, 0x3299], // ㊙
|
|
85
|
+
];
|
|
86
|
+
function isWideBmpEmoji(cp) {
|
|
87
|
+
let lo = 0;
|
|
88
|
+
let hi = WIDE_BMP_EMOJI.length - 1;
|
|
89
|
+
while (lo <= hi) {
|
|
90
|
+
const mid = (lo + hi) >>> 1;
|
|
91
|
+
const [rLo, rHi] = WIDE_BMP_EMOJI[mid];
|
|
92
|
+
if (cp < rLo)
|
|
93
|
+
hi = mid - 1;
|
|
94
|
+
else if (cp > rHi)
|
|
95
|
+
lo = mid + 1;
|
|
96
|
+
else
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Measure the visible terminal width of a string.
|
|
103
|
+
* Strips ANSI escape sequences, then iterates code points:
|
|
104
|
+
* - Surrogate-pair emoji (cp > 0xFFFF): width 2
|
|
105
|
+
* - BMP emoji with Emoji_Presentation=Yes: width 2
|
|
106
|
+
* - VS16 (U+FE0F): width 0 (presentation selector, adds no column)
|
|
107
|
+
* - Everything else: width 1
|
|
108
|
+
*/
|
|
109
|
+
export function visibleLength(s) {
|
|
110
|
+
const stripped = s.replace(ANSI_RE, "");
|
|
111
|
+
let width = 0;
|
|
112
|
+
for (const ch of stripped) {
|
|
113
|
+
const cp = ch.codePointAt(0);
|
|
114
|
+
if (cp === 0xFE0F)
|
|
115
|
+
continue; // VS16 — no terminal width
|
|
116
|
+
if (cp > 0xFFFF || isWideBmpEmoji(cp)) {
|
|
117
|
+
width += 2;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
width += 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return width;
|
|
124
|
+
}
|
|
125
|
+
export const dim = "\x1b[2m";
|
|
126
|
+
export const bold = "\x1b[1m";
|
|
127
|
+
export const reset = "\x1b[0m";
|
|
128
|
+
export const cyan = "\x1b[36m";
|
|
129
|
+
export const green = "\x1b[32m";
|
|
130
|
+
export const yellow = "\x1b[33m";
|
|
131
|
+
export const clearToEol = "\x1b[K";
|
|
132
|
+
export const cursorUp = "\x1b[A";
|
|
133
|
+
/** Reset scroll region to full terminal height. */
|
|
134
|
+
export const RESET_SCROLL_REGION = "\x1b[r";
|
|
135
|
+
/** Clear entire visible screen. */
|
|
136
|
+
export const CLEAR_SCREEN = "\x1b[2J";
|
|
137
|
+
/** Move cursor to row 1, column 1. */
|
|
138
|
+
export const CURSOR_HOME = "\x1b[H";
|
|
139
|
+
/** Show cursor (undo DECTCEM hide). */
|
|
140
|
+
export const SHOW_CURSOR = "\x1b[?25h";
|
|
141
|
+
/** Hide cursor (DECTCEM). */
|
|
142
|
+
export const HIDE_CURSOR = "\x1b[?25l";
|
|
143
|
+
/** Switch to alternate screen buffer. */
|
|
144
|
+
export const ALT_SCREEN_ON = "\x1b[?1049h";
|
|
145
|
+
/** Leave alternate screen buffer. */
|
|
146
|
+
export const ALT_SCREEN_OFF = "\x1b[?1049l";
|
|
147
|
+
export const red = "\x1b[31m";
|
|
148
|
+
export const invert = "\x1b[7m";
|
|
149
|
+
/** CSI (Control Sequence Introducer) prefix for ANSI escape sequences. */
|
|
150
|
+
export const CSI = "\x1b[";
|
|
151
|
+
/** Pad a line with spaces to reach exactly `width` visible characters. */
|
|
152
|
+
export function padToWidth(line, width) {
|
|
153
|
+
const vis = visibleLength(line);
|
|
154
|
+
if (vis < width)
|
|
155
|
+
return line + " ".repeat(width - vis);
|
|
156
|
+
return line;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=ansi.js.map
|
package/dist/ansi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi.js","sourceRoot":"","sources":["../src/ansi.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC;;;;GAIG;AACH,MAAM,cAAc,GAAuB;IACzC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK;IACvB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IACxB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IACxB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK;IACvB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IACxB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IACxB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK;IACvB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK;IACvB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI;IACtB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EAA0E;AAC1E,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC;AAE3B,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,KAAa;IACpD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,GAAG,GAAG,KAAK;QAAE,OAAO,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { runPreflight, computePreflightNeeds } from "./preflight.js";
|
|
4
|
+
import { loadConfig, loadUserConfig, saveUserConfig, resolveYolo, resolveWhipMode, } from "./config.js";
|
|
5
|
+
import { registerBuiltinProviders } from "./agents/index.js";
|
|
6
|
+
import { setProviderVersions } from "./providers/registry.js";
|
|
7
|
+
import { orchestrateWithTemplate } from "./orchestrator.js";
|
|
8
|
+
import { defaultFlowTemplate } from "./flow/built-in/default.js";
|
|
9
|
+
import { whySoSeriousFlowTemplate } from "./flow/built-in/why-so-serious.js";
|
|
10
|
+
import { loadAllFlows } from "./flow/custom/index.js";
|
|
11
|
+
import { resolveFlowParams, toKebabCase, extractFlowParamConfig } from "./flow/params.js";
|
|
12
|
+
import { flowReadsTask } from "./flow/inspect.js";
|
|
13
|
+
import { StatusBar } from "./status-bar.js";
|
|
14
|
+
import { getGitInfo } from "./git-info.js";
|
|
15
|
+
import { setReservedRows } from "./pty/spawn.js";
|
|
16
|
+
import { CLEAR_SCREEN, CURSOR_HOME, RESET_SCROLL_REGION, SHOW_CURSOR } from "./ansi.js";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
18
|
+
const require = createRequire(import.meta.url);
|
|
19
|
+
const { version: PKG_VERSION } = require("../package.json");
|
|
20
|
+
registerBuiltinProviders();
|
|
21
|
+
let orchestrationStarted = false;
|
|
22
|
+
let cleanedUp = false;
|
|
23
|
+
// Static template imports for CLI option registration (before .parse())
|
|
24
|
+
const staticTemplates = [defaultFlowTemplate, whySoSeriousFlowTemplate];
|
|
25
|
+
const program = new Command();
|
|
26
|
+
program
|
|
27
|
+
.name("poly-weaver")
|
|
28
|
+
.description("Orchestrates pluggable AI coding agents in iterative plan-review and implementation-review loops")
|
|
29
|
+
.version(PKG_VERSION)
|
|
30
|
+
.argument("[task]", "Task description or path to task file");
|
|
31
|
+
// Dynamic CLI options from the union of all static templates' params
|
|
32
|
+
const allParams = new Map();
|
|
33
|
+
for (const t of staticTemplates) {
|
|
34
|
+
for (const p of t.params) {
|
|
35
|
+
if (!allParams.has(p.key))
|
|
36
|
+
allParams.set(p.key, p);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const param of allParams.values()) {
|
|
40
|
+
const flag = toKebabCase(param.key);
|
|
41
|
+
switch (param.type) {
|
|
42
|
+
case "driver":
|
|
43
|
+
program.option(`--${flag} <cli>`, param.description ?? param.label);
|
|
44
|
+
break;
|
|
45
|
+
case "number":
|
|
46
|
+
program.option(`--${flag} <n>`, param.description ?? param.label);
|
|
47
|
+
break;
|
|
48
|
+
case "boolean":
|
|
49
|
+
program.option(`--${flag}`, param.description ?? param.label);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Orthogonal options (not in template params)
|
|
54
|
+
program
|
|
55
|
+
.option("--workdir <path>", "Working directory for wrapped CLIs")
|
|
56
|
+
.option("--verbose", "Show orchestrator debug output")
|
|
57
|
+
.option("--opinionless", "Use minimal prompts; let agents decide how to approach each role")
|
|
58
|
+
.option("--no-yolo", "Run agents without auto-approving permissions")
|
|
59
|
+
.option("--whip-mode", "Enable neighbor awareness hints between agents")
|
|
60
|
+
.option("--no-whip-mode", "Disable neighbor awareness hints between agents")
|
|
61
|
+
.option("--config <path>", "Path to config file")
|
|
62
|
+
.option("--workflow <name>", "Workflow template to use");
|
|
63
|
+
program
|
|
64
|
+
.action(async (task, rawOpts) => {
|
|
65
|
+
// 1. Load all flows (built-in + custom)
|
|
66
|
+
const { templates: allTemplates, errors: flowErrors, builtinCount, customDir, } = await loadAllFlows();
|
|
67
|
+
for (const e of flowErrors) {
|
|
68
|
+
console.error(`Warning: skipping flow ${e.file}: ${e.message}`);
|
|
69
|
+
}
|
|
70
|
+
const templateMap = {};
|
|
71
|
+
for (const t of allTemplates) {
|
|
72
|
+
templateMap[t.name] = t;
|
|
73
|
+
}
|
|
74
|
+
// 2. Select template from --workflow flag (BEFORE resolving paramValues)
|
|
75
|
+
let template = templateMap["default"];
|
|
76
|
+
if (rawOpts.workflow) {
|
|
77
|
+
const name = rawOpts.workflow;
|
|
78
|
+
if (!templateMap[name]) {
|
|
79
|
+
console.error(`Unknown workflow: ${name}. Available: ${Object.keys(templateMap).join(", ")}`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
template = templateMap[name];
|
|
83
|
+
}
|
|
84
|
+
// 3. Load configs
|
|
85
|
+
let fileConfig = {};
|
|
86
|
+
if (rawOpts.config && typeof rawOpts.config === "string") {
|
|
87
|
+
fileConfig = await loadConfig(rawOpts.config);
|
|
88
|
+
}
|
|
89
|
+
// Load user-level config (~/.poly-weaver/config.json)
|
|
90
|
+
const userConfig = await loadUserConfig();
|
|
91
|
+
// 4. Extract raw CLI values for flow params into a source record
|
|
92
|
+
// Use allParams (union of all templates) so template-specific flags like --simplifier are captured
|
|
93
|
+
const cliSource = {};
|
|
94
|
+
for (const param of allParams.values()) {
|
|
95
|
+
const raw = rawOpts[param.key];
|
|
96
|
+
if (raw === undefined)
|
|
97
|
+
continue;
|
|
98
|
+
if (param.type === "number" && typeof raw === "string") {
|
|
99
|
+
cliSource[param.key] = parseInt(raw, 10);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
cliSource[param.key] = raw;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 5. Resolve paramValues using SELECTED template's params
|
|
106
|
+
let paramValues = resolveFlowParams(template.params, cliSource, fileConfig, userConfig);
|
|
107
|
+
// Orthogonal options (not resolved via flow params)
|
|
108
|
+
let workdir = rawOpts.workdir ?? process.cwd();
|
|
109
|
+
let verbose = rawOpts.verbose ?? false;
|
|
110
|
+
let opinionless = rawOpts.opinionless
|
|
111
|
+
?? fileConfig.opinionless
|
|
112
|
+
?? userConfig.opinionless
|
|
113
|
+
?? false;
|
|
114
|
+
const noYoloPassed = program.getOptionValueSource('yolo') === 'cli';
|
|
115
|
+
let yolo = resolveYolo(noYoloPassed, fileConfig, userConfig);
|
|
116
|
+
const whipModeCliValue = program.getOptionValueSource('whipMode') === 'cli'
|
|
117
|
+
? rawOpts.whipMode
|
|
118
|
+
: undefined;
|
|
119
|
+
let whipMode = resolveWhipMode(whipModeCliValue, fileConfig, userConfig);
|
|
120
|
+
let taskText = task ?? "";
|
|
121
|
+
// Always show startup TUI on TTY; require task on non-TTY
|
|
122
|
+
if (process.stdin.isTTY) {
|
|
123
|
+
const { showStartupTui, setFlowTemplates } = await import("./startup-tui.js");
|
|
124
|
+
// Inject dynamically loaded templates into TUI
|
|
125
|
+
setFlowTemplates(allTemplates, builtinCount, customDir);
|
|
126
|
+
// Build a CliOptions-compatible defaults object for TUI
|
|
127
|
+
// Pass workflow name so TUI preselects the correct template
|
|
128
|
+
const tuiDefaults = {
|
|
129
|
+
task: taskText,
|
|
130
|
+
workdir,
|
|
131
|
+
verbose,
|
|
132
|
+
opinionless,
|
|
133
|
+
yolo,
|
|
134
|
+
whipMode,
|
|
135
|
+
workflow: template.name,
|
|
136
|
+
...paramValues,
|
|
137
|
+
};
|
|
138
|
+
const result = await showStartupTui(tuiDefaults);
|
|
139
|
+
if (!result)
|
|
140
|
+
process.exit(0); // user cancelled
|
|
141
|
+
// Extract updated values from TUI result
|
|
142
|
+
taskText = result.task;
|
|
143
|
+
workdir = result.workdir;
|
|
144
|
+
verbose = result.verbose;
|
|
145
|
+
opinionless = result.opinionless;
|
|
146
|
+
yolo = result.yolo;
|
|
147
|
+
whipMode = result.whipMode;
|
|
148
|
+
// Look up selected workflow template from TUI result
|
|
149
|
+
template = templateMap[String(result.workflow ?? "default")]
|
|
150
|
+
?? templateMap["default"];
|
|
151
|
+
// Re-extract flow param values from TUI result
|
|
152
|
+
const tuiSource = {};
|
|
153
|
+
for (const param of template.params) {
|
|
154
|
+
const val = result[param.key];
|
|
155
|
+
if (val !== undefined)
|
|
156
|
+
tuiSource[param.key] = val;
|
|
157
|
+
}
|
|
158
|
+
paramValues = resolveFlowParams(template.params, tuiSource);
|
|
159
|
+
// Persist user config (best-effort)
|
|
160
|
+
try {
|
|
161
|
+
const flowParamConfig = extractFlowParamConfig(template.params, paramValues);
|
|
162
|
+
await saveUserConfig({
|
|
163
|
+
...flowParamConfig,
|
|
164
|
+
opinionless,
|
|
165
|
+
yolo,
|
|
166
|
+
whipMode,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
console.error(`Warning: could not save user config: ${err instanceof Error ? err.message : err}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (!taskText) {
|
|
174
|
+
const flow = template.build(paramValues);
|
|
175
|
+
if (flowReadsTask(flow)) {
|
|
176
|
+
program.help();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Preflight checks
|
|
180
|
+
const preflight = await runPreflight(computePreflightNeeds({
|
|
181
|
+
planner: paramValues.planner,
|
|
182
|
+
reviewer: paramValues.reviewer,
|
|
183
|
+
implementor: paramValues.implementor,
|
|
184
|
+
simplifier: paramValues.simplifier,
|
|
185
|
+
planOnly: paramValues.planOnly,
|
|
186
|
+
}));
|
|
187
|
+
setProviderVersions(preflight.versions);
|
|
188
|
+
if (!preflight.ok) {
|
|
189
|
+
console.error("\nPreflight checks failed:\n");
|
|
190
|
+
for (const err of preflight.errors) {
|
|
191
|
+
console.error(` ${err}\n`);
|
|
192
|
+
}
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
const statusBar = new StatusBar();
|
|
196
|
+
setReservedRows(statusBar.reservedRows);
|
|
197
|
+
statusBar.init();
|
|
198
|
+
const gitInfo = await getGitInfo(workdir);
|
|
199
|
+
if (gitInfo)
|
|
200
|
+
statusBar.setGitInfo(gitInfo);
|
|
201
|
+
orchestrationStarted = true;
|
|
202
|
+
let exitCode = 0;
|
|
203
|
+
let exitMessage = "";
|
|
204
|
+
try {
|
|
205
|
+
const result = await orchestrateWithTemplate({
|
|
206
|
+
template,
|
|
207
|
+
paramValues,
|
|
208
|
+
task: taskText,
|
|
209
|
+
verbose,
|
|
210
|
+
opinionless,
|
|
211
|
+
yolo,
|
|
212
|
+
whipMode,
|
|
213
|
+
workdir,
|
|
214
|
+
statusBar,
|
|
215
|
+
});
|
|
216
|
+
if (result.approved) {
|
|
217
|
+
const implInfo = result.implementation
|
|
218
|
+
? ` Implementation approved after ${result.implementation.iterations} iteration(s).`
|
|
219
|
+
: "";
|
|
220
|
+
exitCode = 0;
|
|
221
|
+
exitMessage = `\nPlan approved after ${result.iterations} iteration(s).${implInfo}`;
|
|
222
|
+
}
|
|
223
|
+
else if (result.implementation && !result.implementation.approved) {
|
|
224
|
+
exitCode = 2;
|
|
225
|
+
exitMessage = `\nPlan approved, but implementation NOT approved after ` +
|
|
226
|
+
`${result.implementation.iterations} iteration(s).`;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
exitCode = 2;
|
|
230
|
+
exitMessage = `\nPlan was NOT approved after ${result.iterations} iteration(s).`;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
exitCode = 1;
|
|
235
|
+
exitMessage = `\nFatal error: ${err instanceof Error ? err.message : err}`;
|
|
236
|
+
if (verbose && err instanceof Error) {
|
|
237
|
+
exitMessage += `\n${err.stack}`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
statusBar.destroy();
|
|
242
|
+
setReservedRows(0);
|
|
243
|
+
if (process.stdout.isTTY) {
|
|
244
|
+
process.stdout.write(CLEAR_SCREEN + CURSOR_HOME + SHOW_CURSOR);
|
|
245
|
+
}
|
|
246
|
+
cleanedUp = true;
|
|
247
|
+
}
|
|
248
|
+
// Print summary on the now-clean screen, then exit
|
|
249
|
+
if (exitCode === 1) {
|
|
250
|
+
console.error(exitMessage);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
console.log(exitMessage);
|
|
254
|
+
}
|
|
255
|
+
process.exit(exitCode);
|
|
256
|
+
});
|
|
257
|
+
// Best-effort cleanup — clears the screen so the terminal is usable
|
|
258
|
+
// even after SIGINT, unhandled exception, or other abrupt termination.
|
|
259
|
+
// Skips if the `finally` block already cleaned up (preserves summary message).
|
|
260
|
+
process.on("exit", () => {
|
|
261
|
+
if (process.stdout.isTTY && orchestrationStarted && !cleanedUp) {
|
|
262
|
+
process.stdout.write(RESET_SCROLL_REGION + CLEAR_SCREEN + CURSOR_HOME + SHOW_CURSOR);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
async function runFlowCommand(launcher) {
|
|
266
|
+
if (!process.stdout.isTTY) {
|
|
267
|
+
console.error("This command requires an interactive terminal");
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
270
|
+
const result = await launcher();
|
|
271
|
+
if (result?.saved) {
|
|
272
|
+
console.log(`Flow saved to: ${result.filePath}`);
|
|
273
|
+
if (result.backedUp) {
|
|
274
|
+
console.log(`Backup created: ${result.backedUp}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
console.log("Cancelled.");
|
|
279
|
+
}
|
|
280
|
+
process.exit(0);
|
|
281
|
+
}
|
|
282
|
+
program
|
|
283
|
+
.command("create-flow")
|
|
284
|
+
.description("Create a new custom flow template using LLM assistance")
|
|
285
|
+
.action(() => runFlowCommand(async () => {
|
|
286
|
+
const { showCreateFlowTui } = await import("./flow-editor/tui.js");
|
|
287
|
+
return showCreateFlowTui();
|
|
288
|
+
}));
|
|
289
|
+
program
|
|
290
|
+
.command("modify-flow")
|
|
291
|
+
.description("Modify an existing custom flow template using LLM assistance")
|
|
292
|
+
.action(async () => {
|
|
293
|
+
try {
|
|
294
|
+
await runFlowCommand(async () => {
|
|
295
|
+
const { showModifyFlowTui } = await import("./flow-editor/tui.js");
|
|
296
|
+
return showModifyFlowTui();
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
if (err instanceof Error && err.name === "NoCustomFlowsError") {
|
|
301
|
+
console.error(err.message);
|
|
302
|
+
console.error("Use 'create-flow' to create a custom flow first.");
|
|
303
|
+
process.exit(1);
|
|
304
|
+
}
|
|
305
|
+
throw err;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
program.parse();
|
|
309
|
+
//# sourceMappingURL=cli.js.map
|