@tiic-tech/openworkflow 0.1.0 → 0.1.2
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 +10 -0
- package/dist/adapters/codex/src/cleanCodexAdapter.d.ts +7 -0
- package/dist/adapters/codex/src/cleanCodexAdapter.js +99 -0
- package/dist/adapters/codex/src/cleanCodexAdapter.js.map +1 -0
- package/dist/adapters/codex/src/constants.d.ts +1 -0
- package/dist/adapters/codex/src/constants.js +2 -0
- package/dist/adapters/codex/src/constants.js.map +1 -0
- package/dist/adapters/codex/src/generateCommands.js +14 -9
- package/dist/adapters/codex/src/generateCommands.js.map +1 -1
- package/dist/adapters/codex/src/generateSkills.js +13 -0
- package/dist/adapters/codex/src/generateSkills.js.map +1 -1
- package/dist/adapters/codex/src/generatedFiles.js +1 -1
- package/dist/adapters/codex/src/manifest.js +11 -2
- package/dist/adapters/codex/src/manifest.js.map +1 -1
- package/dist/adapters/codex/src/templates.d.ts +0 -1
- package/dist/adapters/codex/src/templates.js +0 -1
- package/dist/adapters/codex/src/templates.js.map +1 -1
- package/dist/adapters/src/registry.d.ts +20 -0
- package/dist/adapters/src/registry.js +81 -0
- package/dist/adapters/src/registry.js.map +1 -0
- package/dist/cli/src/commands/brief.d.ts +46 -0
- package/dist/cli/src/commands/brief.js +294 -0
- package/dist/cli/src/commands/brief.js.map +1 -0
- package/dist/cli/src/commands/check.d.ts +42 -0
- package/dist/cli/src/commands/check.js +326 -0
- package/dist/cli/src/commands/check.js.map +1 -0
- package/dist/cli/src/commands/clean.d.ts +1 -0
- package/dist/cli/src/commands/clean.js +98 -0
- package/dist/cli/src/commands/clean.js.map +1 -0
- package/dist/cli/src/commands/context.d.ts +1 -0
- package/dist/cli/src/commands/context.js +471 -0
- package/dist/cli/src/commands/context.js.map +1 -0
- package/dist/cli/src/commands/doctor.js +122 -12
- package/dist/cli/src/commands/doctor.js.map +1 -1
- package/dist/cli/src/commands/draft.d.ts +1 -0
- package/dist/cli/src/commands/draft.js +175 -0
- package/dist/cli/src/commands/draft.js.map +1 -0
- package/dist/cli/src/commands/gitAutomation.d.ts +1 -0
- package/dist/cli/src/commands/gitAutomation.js +378 -0
- package/dist/cli/src/commands/gitAutomation.js.map +1 -0
- package/dist/cli/src/commands/handoff.d.ts +22 -0
- package/dist/cli/src/commands/handoff.js +122 -0
- package/dist/cli/src/commands/handoff.js.map +1 -0
- package/dist/cli/src/commands/init.js +52 -1
- package/dist/cli/src/commands/init.js.map +1 -1
- package/dist/cli/src/commands/inspect.d.ts +23 -0
- package/dist/cli/src/commands/inspect.js +157 -0
- package/dist/cli/src/commands/inspect.js.map +1 -0
- package/dist/cli/src/commands/register.d.ts +1 -0
- package/dist/cli/src/commands/register.js +251 -0
- package/dist/cli/src/commands/register.js.map +1 -0
- package/dist/cli/src/commands/resume.d.ts +59 -0
- package/dist/cli/src/commands/resume.js +280 -0
- package/dist/cli/src/commands/resume.js.map +1 -0
- package/dist/cli/src/commands/shared.js +6 -2
- package/dist/cli/src/commands/shared.js.map +1 -1
- package/dist/cli/src/commands/summaries.d.ts +1 -0
- package/dist/cli/src/commands/summaries.js +77 -0
- package/dist/cli/src/commands/summaries.js.map +1 -0
- package/dist/cli/src/commands/summarize.d.ts +1 -0
- package/dist/cli/src/commands/summarize.js +316 -0
- package/dist/cli/src/commands/summarize.js.map +1 -0
- package/dist/cli/src/commands/sync.js +135 -12
- package/dist/cli/src/commands/sync.js.map +1 -1
- package/dist/cli/src/commands/validate.js +25 -1
- package/dist/cli/src/commands/validate.js.map +1 -1
- package/dist/cli/src/dev/verifyAgentE2E.d.ts +2 -0
- package/dist/cli/src/dev/verifyAgentE2E.js +391 -0
- package/dist/cli/src/dev/verifyAgentE2E.js.map +1 -0
- package/dist/cli/src/dev/verifyCleanCommand.d.ts +2 -0
- package/dist/cli/src/dev/verifyCleanCommand.js +338 -0
- package/dist/cli/src/dev/verifyCleanCommand.js.map +1 -0
- package/dist/cli/src/dev/verifyRuntimeSurface.js +4940 -54
- package/dist/cli/src/dev/verifyRuntimeSurface.js.map +1 -1
- package/dist/cli/src/dev/verifyWorkflowE2E.js +477 -45
- package/dist/cli/src/dev/verifyWorkflowE2E.js.map +1 -1
- package/dist/cli/src/index.js +189 -5
- package/dist/cli/src/index.js.map +1 -1
- package/dist/cli/src/report.d.ts +26 -0
- package/dist/cli/src/report.js +17 -0
- package/dist/cli/src/report.js.map +1 -0
- package/dist/core/src/artifacts/readiness.d.ts +7 -0
- package/dist/core/src/artifacts/readiness.js +240 -0
- package/dist/core/src/artifacts/readiness.js.map +1 -0
- package/dist/core/src/artifacts/registry.d.ts +9 -2
- package/dist/core/src/artifacts/registry.js +687 -60
- package/dist/core/src/artifacts/registry.js.map +1 -1
- package/dist/core/src/commands/registry.js +1425 -146
- package/dist/core/src/commands/registry.js.map +1 -1
- package/dist/core/src/contracts/index.d.ts +1 -1
- package/dist/core/src/fs/index.d.ts +24 -0
- package/dist/core/src/fs/index.js +48 -1
- package/dist/core/src/fs/index.js.map +1 -1
- package/dist/core/src/git/autonomousSimulator.d.ts +46 -0
- package/dist/core/src/git/autonomousSimulator.js +163 -0
- package/dist/core/src/git/autonomousSimulator.js.map +1 -0
- package/dist/core/src/git/branchIdentity.d.ts +19 -0
- package/dist/core/src/git/branchIdentity.js +75 -0
- package/dist/core/src/git/branchIdentity.js.map +1 -0
- package/dist/core/src/git/draftPrPilot.d.ts +47 -0
- package/dist/core/src/git/draftPrPilot.js +196 -0
- package/dist/core/src/git/draftPrPilot.js.map +1 -0
- package/dist/core/src/git/localEvidenceReader.d.ts +21 -0
- package/dist/core/src/git/localEvidenceReader.js +142 -0
- package/dist/core/src/git/localEvidenceReader.js.map +1 -0
- package/dist/core/src/git/localGitAutomation.d.ts +68 -0
- package/dist/core/src/git/localGitAutomation.js +470 -0
- package/dist/core/src/git/localGitAutomation.js.map +1 -0
- package/dist/core/src/git/mergeReadinessCheckpoint.d.ts +31 -0
- package/dist/core/src/git/mergeReadinessCheckpoint.js +110 -0
- package/dist/core/src/git/mergeReadinessCheckpoint.js.map +1 -0
- package/dist/core/src/git/prReadySummary.d.ts +16 -0
- package/dist/core/src/git/prReadySummary.js +144 -0
- package/dist/core/src/git/prReadySummary.js.map +1 -0
- package/dist/core/src/git/remoteReadonlyPlanner.d.ts +60 -0
- package/dist/core/src/git/remoteReadonlyPlanner.js +223 -0
- package/dist/core/src/git/remoteReadonlyPlanner.js.map +1 -0
- package/dist/core/src/onboarding/agentsGuide.d.ts +32 -0
- package/dist/core/src/onboarding/agentsGuide.js +164 -0
- package/dist/core/src/onboarding/agentsGuide.js.map +1 -0
- package/dist/core/src/validators/validateOpenWorkflow.js +1331 -15
- package/dist/core/src/validators/validateOpenWorkflow.js.map +1 -1
- package/dist/core/src/validators/validateRepositoryContracts.js +2327 -306
- package/dist/core/src/validators/validateRepositoryContracts.js.map +1 -1
- package/dist/core/src/workflow/cleanOpenWorkflow.d.ts +18 -0
- package/dist/core/src/workflow/cleanOpenWorkflow.js +124 -0
- package/dist/core/src/workflow/cleanOpenWorkflow.js.map +1 -0
- package/dist/core/src/workflow/doctorOpenWorkflow.d.ts +7 -0
- package/dist/core/src/workflow/doctorOpenWorkflow.js +26 -0
- package/dist/core/src/workflow/doctorOpenWorkflow.js.map +1 -0
- package/dist/core/src/workflow/initOpenWorkflow.d.ts +7 -0
- package/dist/core/src/workflow/initOpenWorkflow.js +96 -8
- package/dist/core/src/workflow/initOpenWorkflow.js.map +1 -1
- package/dist/core/src/workflow/planningQueueResume.d.ts +105 -0
- package/dist/core/src/workflow/planningQueueResume.js +596 -0
- package/dist/core/src/workflow/planningQueueResume.js.map +1 -0
- package/dist/core/src/workflow/readWorkflowConfig.d.ts +6 -0
- package/dist/core/src/workflow/readWorkflowConfig.js +28 -0
- package/dist/core/src/workflow/readWorkflowConfig.js.map +1 -0
- package/dist/core/src/workflow/summaryHealth.d.ts +60 -0
- package/dist/core/src/workflow/summaryHealth.js +713 -0
- package/dist/core/src/workflow/summaryHealth.js.map +1 -0
- package/dist/core/src/workflow/syncOpenWorkflow.d.ts +22 -0
- package/dist/core/src/workflow/syncOpenWorkflow.js +235 -0
- package/dist/core/src/workflow/syncOpenWorkflow.js.map +1 -0
- package/package.json +4 -2
- package/references/artifact-authoring-templates.md +14 -12
- package/references/artifact-instruction-envelope.md +133 -0
- package/references/coder-continuous-growth-loop.md +68 -0
- package/references/gh-operation-governance.md +114 -0
- package/references/git-automation-governance.md +324 -0
- package/references/git-version-control-governance.md +227 -0
- package/references/internal-coder-protocol.md +202 -0
- package/references/issue-governance.md +115 -0
- package/references/planning-artifact-contracts.md +595 -0
- package/references/planning-skill-runtime-exposure.md +159 -0
- package/references/proto-redesign-artifact-contracts.md +217 -0
- package/references/proto2html-artifact-contracts.md +113 -0
- package/references/skill-system-lifecycle.md +198 -0
- package/references/validation-trust-domains.md +286 -0
- package/references/workflow-blueprint-runtime-alignment.md +287 -0
- package/schemas/atom-tasks.schema.json +101 -0
- package/schemas/candidate-changes.schema.json +323 -0
- package/schemas/current-state.schema.json +113 -0
- package/schemas/html-prototype.schema.json +288 -0
- package/schemas/openworkflow-contract.schema.json +9 -1
- package/schemas/proto-prompt-pack.schema.json +1333 -0
- package/schemas/prototype-evidence.schema.json +684 -142
- package/schemas/selected-change.schema.json +104 -0
- package/schemas/validation-target.schema.json +187 -1
- package/schemas/validation.schema.json +187 -1
- package/schemas/vision-session.schema.json +151 -0
- package/skills/analyze-changes/SKILL.md +92 -0
- package/skills/analyze-changes/agents/openai.yaml +4 -0
- package/skills/analyze-changes/references/analysis-protocol.md +116 -0
- package/skills/build-proto-prompt/SKILL.md +125 -0
- package/skills/build-proto-prompt/references/output-boundary.md +54 -0
- package/skills/build-proto-prompt/references/prompt-pack-compiler-protocol.md +80 -0
- package/skills/build-prototype/SKILL.md +162 -38
- package/skills/build-prototype/agents/openai.yaml +2 -2
- package/skills/build-prototype/references/philosophy-engine.md +61 -0
- package/skills/build-prototype/references/strategic-prompt-pack-protocol.md +365 -0
- package/skills/build-prototype/references/vision2prompt/01_input_contract.md +84 -0
- package/skills/build-prototype/references/vision2prompt/02_vision_decomposition.md +108 -0
- package/skills/build-prototype/references/vision2prompt/03_strategy_hypothesis_generation.md +89 -0
- package/skills/build-prototype/references/vision2prompt/04_product_system_extraction.md +78 -0
- package/skills/build-prototype/references/vision2prompt/05_prototype_prompt_schema.md +189 -0
- package/skills/build-prototype/references/vision2prompt/06_output_templates.md +125 -0
- package/skills/build-prototype/references/vision2prompt/07_quality_rubric.md +171 -0
- package/skills/build-validation/SKILL.md +136 -54
- package/skills/build-validation/references/prototype-validation-target-rubric.md +35 -0
- package/skills/build-validation/references/return-to-vision-gate.md +32 -0
- package/skills/build-vision/SKILL.md +192 -0
- package/skills/build-vision/references/proto-readiness-rubric.md +48 -0
- package/skills/build-vision/references/vision-interview-protocol.md +48 -0
- package/skills/coder/SKILL.md +204 -0
- package/skills/decompose-to-changes/SKILL.md +176 -0
- package/skills/decompose-to-changes/agents/openai.yaml +4 -0
- package/skills/decompose-to-changes/references/decomposition-protocol.md +278 -0
- package/skills/prompt2proto/SKILL.md +157 -0
- package/skills/prompt2proto/agents/openai.yaml +4 -0
- package/skills/prompt2proto/references/00_role_philosophy_engine.md +96 -0
- package/skills/prompt2proto/references/01_input_contract.md +53 -0
- package/skills/prompt2proto/references/02_prompt_pack_readiness.md +50 -0
- package/skills/prompt2proto/references/03_visual_translation_workflow.md +64 -0
- package/skills/prompt2proto/references/04_output_contract.md +67 -0
- package/skills/prompt2proto/references/05_quality_rubric.md +46 -0
- package/skills/proto2html/SKILL.md +136 -0
- package/skills/proto2html/agents/openai.yaml +4 -0
- package/skills/proto2html/references/proto2html-protocol.md +115 -0
- package/skills/run-team/SKILL.md +4 -0
- package/skills/select-change/SKILL.md +200 -0
- package/skills/select-change/agents/openai.yaml +4 -0
- package/skills/select-change/references/selection-protocol.md +281 -0
- package/skills/tune-prototype/SKILL.md +121 -0
- package/skills/tune-prototype/agents/openai.yaml +4 -0
- package/skills/tune-prototype/references/refined-prompt-pack-protocol.md +161 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { detectAdapterPlatforms, getAdapterEntry } from "../../../adapters/src/registry.js";
|
|
5
|
+
import { parseYaml } from "../../../core/src/contracts/yaml.js";
|
|
6
|
+
import { isNotFound, readTextFile } from "../../../core/src/fs/index.js";
|
|
7
|
+
import { doctorAgentsGuide } from "../../../core/src/onboarding/agentsGuide.js";
|
|
8
|
+
import { doctorOpenWorkflow } from "../../../core/src/workflow/doctorOpenWorkflow.js";
|
|
9
|
+
import { readWorkflowConfig } from "../../../core/src/workflow/readWorkflowConfig.js";
|
|
10
|
+
import { evaluateSummaryHealth } from "../../../core/src/workflow/summaryHealth.js";
|
|
11
|
+
import { booleanFlag, stringFlag } from "../args.js";
|
|
12
|
+
import { emptyEffects, printJsonReport } from "../report.js";
|
|
13
|
+
import { basenameForTitle, parseTools, slugify } from "./shared.js";
|
|
14
|
+
const execFileAsync = promisify(execFile);
|
|
15
|
+
export async function briefCommand(command, flags) {
|
|
16
|
+
const root = resolve(stringFlag(flags, "root", ".") ?? ".");
|
|
17
|
+
const json = booleanFlag(flags, "json");
|
|
18
|
+
const model = await buildBriefModel(root, parseTools(stringFlag(flags, "tools")));
|
|
19
|
+
if (json) {
|
|
20
|
+
const healthErrors = healthErrorsForBrief(model);
|
|
21
|
+
printJsonReport({
|
|
22
|
+
command,
|
|
23
|
+
ok: model.health.ok,
|
|
24
|
+
root,
|
|
25
|
+
data: model,
|
|
26
|
+
warnings: model.health.workflow.warnings.concat(model.health.agents_md.warnings, Object.values(model.health.adapters).flatMap((section) => section.warnings), model.health.summaries.warnings),
|
|
27
|
+
errors: model.health.workflow.errors.concat(model.health.agents_md.errors, Object.values(model.health.adapters).flatMap((section) => section.errors)),
|
|
28
|
+
health_errors: healthErrors,
|
|
29
|
+
effects: emptyEffects(),
|
|
30
|
+
next_actions: [model.agent_guidance.recommended_next_action],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
printBrief(model);
|
|
35
|
+
}
|
|
36
|
+
return model.health.ok ? 0 : 1;
|
|
37
|
+
}
|
|
38
|
+
export function healthErrorsForBrief(model) {
|
|
39
|
+
if (model.health.ok) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
return unique([
|
|
43
|
+
...healthSectionErrors("workflow", model.health.workflow),
|
|
44
|
+
...healthSectionErrors("agents_md", model.health.agents_md),
|
|
45
|
+
...Object.entries(model.health.adapters).flatMap(([tool, section]) => healthSectionErrors(`adapter:${tool}`, section)),
|
|
46
|
+
...(!model.health.summaries.ok ? model.health.summaries.warnings : []),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
function healthSectionErrors(label, section) {
|
|
50
|
+
if (section.ok) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const items = section.errors.length > 0 ? section.errors : section.warnings;
|
|
54
|
+
return items.map((item) => `${label}: ${item}`);
|
|
55
|
+
}
|
|
56
|
+
export async function buildBriefModel(root, explicitTools) {
|
|
57
|
+
const config = await readWorkflowConfig(root);
|
|
58
|
+
const detection = await detectAdapterPlatforms(root);
|
|
59
|
+
const autoTools = explicitTools.length === 0 || explicitTools.includes("auto");
|
|
60
|
+
const tools = autoTools ? detection.detected : explicitTools;
|
|
61
|
+
const workflowTools = autoTools ? uniqueTools([...tools, ...detection.unknownConfigured]) : tools;
|
|
62
|
+
const projectTitle = config?.projectTitle ?? basenameForTitle(root);
|
|
63
|
+
const projectSlug = slugify(config?.projectSlug ?? projectTitle);
|
|
64
|
+
const currentState = await readCurrentState(root);
|
|
65
|
+
const workflowHealth = await doctorOpenWorkflow({
|
|
66
|
+
root,
|
|
67
|
+
projectTitle,
|
|
68
|
+
projectSlug,
|
|
69
|
+
tools: workflowTools,
|
|
70
|
+
force: false,
|
|
71
|
+
});
|
|
72
|
+
const agentsGuideHealth = await doctorAgentsGuide(root);
|
|
73
|
+
const summaryHealth = await evaluateSummaryHealth(root);
|
|
74
|
+
const adapterHealth = {};
|
|
75
|
+
for (const tool of tools) {
|
|
76
|
+
const adapter = getAdapterEntry(tool);
|
|
77
|
+
if (!adapter) {
|
|
78
|
+
adapterHealth[tool] = {
|
|
79
|
+
ok: false,
|
|
80
|
+
warnings: [],
|
|
81
|
+
errors: [`unsupported adapter platform: ${tool}`],
|
|
82
|
+
};
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
adapterHealth[tool] = await adapter.doctor(root);
|
|
86
|
+
}
|
|
87
|
+
for (const tool of detection.unknownConfigured) {
|
|
88
|
+
adapterHealth[tool] = {
|
|
89
|
+
ok: false,
|
|
90
|
+
warnings: [`configured tool is not supported by this OpenWorkflow version: ${tool}`],
|
|
91
|
+
errors: [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const health = {
|
|
95
|
+
ok: workflowHealth.ok && agentsGuideHealth.ok && summaryHealth.ok && Object.values(adapterHealth).every((item) => item.ok),
|
|
96
|
+
workflow: workflowHealth,
|
|
97
|
+
adapters: adapterHealth,
|
|
98
|
+
agents_md: agentsGuideHealth,
|
|
99
|
+
summaries: summaryHealth,
|
|
100
|
+
recommended_maintenance: maintenanceAction(workflowHealth, agentsGuideHealth, adapterHealth, summaryHealth),
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
project: {
|
|
104
|
+
title: projectTitle,
|
|
105
|
+
slug: projectSlug,
|
|
106
|
+
root,
|
|
107
|
+
tools: config?.tools ?? [],
|
|
108
|
+
detected_tools: detection.detected,
|
|
109
|
+
unknown_configured_tools: detection.unknownConfigured,
|
|
110
|
+
},
|
|
111
|
+
workflow: {
|
|
112
|
+
active_stage: stringOrNull(currentState?.active_stage),
|
|
113
|
+
next_command: stringOrNull(currentState?.next_command),
|
|
114
|
+
blocked_by: stringList(currentState?.blocked_by),
|
|
115
|
+
last_decision: isRecord(currentState?.last_decision) ? currentState.last_decision : null,
|
|
116
|
+
},
|
|
117
|
+
read_this_first: stringList(currentState?.read_this_first),
|
|
118
|
+
active_pointers: activePointers(currentState),
|
|
119
|
+
health,
|
|
120
|
+
git: await gitState(root),
|
|
121
|
+
agent_guidance: {
|
|
122
|
+
recommended_next_action: recommendedNextAction(currentState, health),
|
|
123
|
+
safe_to_modify: ["Files required by the current task after checking git status and active pointers."],
|
|
124
|
+
do_not_touch: [
|
|
125
|
+
"Existing user artifacts or notes unless the current task explicitly requires them.",
|
|
126
|
+
"Stage artifacts not produced by the current /ow:* command.",
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async function readCurrentState(root) {
|
|
132
|
+
try {
|
|
133
|
+
const data = parseYaml(await readTextFile(join(root, ".openworkflow", "CURRENT_STATE.yaml")));
|
|
134
|
+
return isRecord(data) ? data : null;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (isNotFound(error)) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function printBrief(model) {
|
|
144
|
+
console.log(`OpenWorkflow brief for ${model.project.title}`);
|
|
145
|
+
console.log(`root: ${model.project.root}`);
|
|
146
|
+
console.log(`tools: ${formatList(model.project.detected_tools.length > 0 ? model.project.detected_tools : model.project.tools)}`);
|
|
147
|
+
console.log("");
|
|
148
|
+
console.log("Workflow:");
|
|
149
|
+
console.log(` active_stage: ${model.workflow.active_stage ?? "unknown"}`);
|
|
150
|
+
console.log(` next_command: ${model.workflow.next_command ?? "none"}`);
|
|
151
|
+
console.log(` blocked_by: ${formatList(model.workflow.blocked_by)}`);
|
|
152
|
+
console.log(` last_decision: ${formatRecord(model.workflow.last_decision)}`);
|
|
153
|
+
console.log("");
|
|
154
|
+
console.log("Read this first:");
|
|
155
|
+
for (const item of model.read_this_first.length > 0 ? model.read_this_first : ["none"]) {
|
|
156
|
+
console.log(` - ${item}`);
|
|
157
|
+
}
|
|
158
|
+
console.log("");
|
|
159
|
+
console.log("Active pointers:");
|
|
160
|
+
for (const [key, value] of Object.entries(model.active_pointers)) {
|
|
161
|
+
console.log(` ${key}: ${value ?? "none"}`);
|
|
162
|
+
}
|
|
163
|
+
console.log("");
|
|
164
|
+
console.log("Health:");
|
|
165
|
+
console.log(` ok: ${model.health.ok}`);
|
|
166
|
+
console.log(` workflow: ${healthLabel(model.health.workflow)}`);
|
|
167
|
+
console.log(` agents_md: ${healthLabel(model.health.agents_md)}`);
|
|
168
|
+
console.log(` summaries: current=${model.health.summaries.counts.current}, missing=${model.health.summaries.counts.missing}, stale_unknown=${model.health.summaries.counts.stale_unknown}, not_instantiated=${model.health.summaries.counts.not_instantiated}`);
|
|
169
|
+
for (const [tool, section] of Object.entries(model.health.adapters)) {
|
|
170
|
+
console.log(` adapter:${tool}: ${healthLabel(section)}`);
|
|
171
|
+
}
|
|
172
|
+
console.log(` recommended_maintenance: ${model.health.recommended_maintenance ?? "none"}`);
|
|
173
|
+
console.log("");
|
|
174
|
+
console.log("Git:");
|
|
175
|
+
console.log(` available: ${model.git.available}`);
|
|
176
|
+
console.log(` branch: ${model.git.branch ?? "none"}`);
|
|
177
|
+
console.log(` dirty: ${model.git.dirty}`);
|
|
178
|
+
console.log(` changed_files: ${formatList(model.git.changed_files)}`);
|
|
179
|
+
console.log("");
|
|
180
|
+
console.log("Agent guidance:");
|
|
181
|
+
console.log(` recommended_next_action: ${model.agent_guidance.recommended_next_action}`);
|
|
182
|
+
}
|
|
183
|
+
function healthLabel(section) {
|
|
184
|
+
if (section.errors.length > 0) {
|
|
185
|
+
return `errors=${section.errors.length}, warnings=${section.warnings.length}`;
|
|
186
|
+
}
|
|
187
|
+
if (section.warnings.length > 0) {
|
|
188
|
+
return `warnings=${section.warnings.length}`;
|
|
189
|
+
}
|
|
190
|
+
return "ok";
|
|
191
|
+
}
|
|
192
|
+
function maintenanceAction(workflow, agentsGuide, adapters, summaries) {
|
|
193
|
+
const hasSyncFixableDrift = workflow.errors.length > 0
|
|
194
|
+
|| workflow.warnings.length > 0
|
|
195
|
+
|| agentsGuide.warnings.length > 0
|
|
196
|
+
|| Object.values(adapters).some((section) => section.errors.length > 0 || section.warnings.length > 0);
|
|
197
|
+
if (hasSyncFixableDrift) {
|
|
198
|
+
return "run openworkflow sync, then openworkflow doctor";
|
|
199
|
+
}
|
|
200
|
+
if (!summaries.ok) {
|
|
201
|
+
return summaries.initialized
|
|
202
|
+
? "run openworkflow summaries --json before relying on low-context artifact reads"
|
|
203
|
+
: "run openworkflow init or sync before relying on OpenWorkflow read models";
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
function recommendedNextAction(currentState, health) {
|
|
208
|
+
if (health.recommended_maintenance) {
|
|
209
|
+
return health.recommended_maintenance;
|
|
210
|
+
}
|
|
211
|
+
const nextCommand = stringOrNull(currentState?.next_command);
|
|
212
|
+
return nextCommand ? `continue with ${nextCommand}` : "inspect CURRENT_STATE.yaml and choose the next workflow command";
|
|
213
|
+
}
|
|
214
|
+
function activePointers(currentState) {
|
|
215
|
+
const keys = [
|
|
216
|
+
"current_vision",
|
|
217
|
+
"current_validation",
|
|
218
|
+
"current_prototype",
|
|
219
|
+
"current_decision",
|
|
220
|
+
"current_design",
|
|
221
|
+
"current_spec",
|
|
222
|
+
"current_change",
|
|
223
|
+
"current_run",
|
|
224
|
+
];
|
|
225
|
+
return Object.fromEntries(keys.map((key) => [key, currentPointerValue(currentState, key)]));
|
|
226
|
+
}
|
|
227
|
+
function currentPointerValue(currentState, key) {
|
|
228
|
+
const direct = stringOrNull(currentState?.[key]);
|
|
229
|
+
if (direct || key !== "current_vision") {
|
|
230
|
+
return direct;
|
|
231
|
+
}
|
|
232
|
+
return stringOrNull(currentState?.current_session);
|
|
233
|
+
}
|
|
234
|
+
async function gitState(root) {
|
|
235
|
+
try {
|
|
236
|
+
await execGit(root, ["rev-parse", "--is-inside-work-tree"]);
|
|
237
|
+
const branch = await gitBranch(root);
|
|
238
|
+
const status = await execGit(root, ["status", "--porcelain"]);
|
|
239
|
+
const changedFiles = status.split("\n").filter(Boolean).map((line) => line.slice(3).trim()).filter(Boolean);
|
|
240
|
+
return {
|
|
241
|
+
available: true,
|
|
242
|
+
branch,
|
|
243
|
+
dirty: changedFiles.length > 0,
|
|
244
|
+
changed_files: changedFiles,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return {
|
|
249
|
+
available: false,
|
|
250
|
+
branch: null,
|
|
251
|
+
dirty: false,
|
|
252
|
+
changed_files: [],
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async function gitBranch(root) {
|
|
257
|
+
try {
|
|
258
|
+
const branch = (await execGit(root, ["branch", "--show-current"])).trim();
|
|
259
|
+
return branch.length > 0 ? branch : null;
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async function execGit(root, args) {
|
|
266
|
+
const { stdout } = await execFileAsync("git", args, { cwd: root });
|
|
267
|
+
return stdout;
|
|
268
|
+
}
|
|
269
|
+
function formatList(items) {
|
|
270
|
+
return items.length > 0 ? items.join(", ") : "none";
|
|
271
|
+
}
|
|
272
|
+
function formatRecord(value) {
|
|
273
|
+
if (!value) {
|
|
274
|
+
return "none";
|
|
275
|
+
}
|
|
276
|
+
const outcome = value.outcome;
|
|
277
|
+
return typeof outcome === "string" && outcome.length > 0 ? outcome : "none";
|
|
278
|
+
}
|
|
279
|
+
function stringList(value) {
|
|
280
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
281
|
+
}
|
|
282
|
+
function stringOrNull(value) {
|
|
283
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
284
|
+
}
|
|
285
|
+
function uniqueTools(tools) {
|
|
286
|
+
return [...new Set(tools)];
|
|
287
|
+
}
|
|
288
|
+
function unique(values) {
|
|
289
|
+
return [...new Set(values.filter((value) => value.trim().length > 0))];
|
|
290
|
+
}
|
|
291
|
+
function isRecord(value) {
|
|
292
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=brief.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief.js","sourceRoot":"","sources":["../../../../packages/cli/src/commands/brief.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAA2B,MAAM,6CAA6C,CAAC;AAC7G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AA8C1C,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAA2B,EAAE,KAAoC;IAClG,MAAM,IAAI,GAAG,OA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gB;IAC9B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface ReadinessModel {
|
|
2
|
+
command: string | null;
|
|
3
|
+
normalized_command: string | null;
|
|
4
|
+
ready: boolean;
|
|
5
|
+
blockers: string[];
|
|
6
|
+
warnings: string[];
|
|
7
|
+
required_context: ContextStatus[];
|
|
8
|
+
optional_context: ContextStatus[];
|
|
9
|
+
forbidden_context: ContextStatus[];
|
|
10
|
+
conditional_context: string[];
|
|
11
|
+
allowed_outputs: string[];
|
|
12
|
+
forbidden_outputs: string[];
|
|
13
|
+
handoff_commands: string[];
|
|
14
|
+
artifact_contracts: ArtifactSummary[];
|
|
15
|
+
semantic_readiness: SemanticReadinessSummary | null;
|
|
16
|
+
summary_guidance: SummaryGuidance[];
|
|
17
|
+
read_this_first: string[];
|
|
18
|
+
active_pointers: Record<string, string | null>;
|
|
19
|
+
next_actions: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface ContextStatus {
|
|
22
|
+
path: string;
|
|
23
|
+
exists: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ArtifactSummary {
|
|
26
|
+
artifact_type: string;
|
|
27
|
+
source_of_truth_path: string;
|
|
28
|
+
summary_policy: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface SummaryGuidance {
|
|
31
|
+
artifact_type: string;
|
|
32
|
+
status: string;
|
|
33
|
+
next_actions: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface SemanticReadinessSummary {
|
|
36
|
+
gate_status: string | null;
|
|
37
|
+
ok: boolean;
|
|
38
|
+
blockers: string[];
|
|
39
|
+
warnings: string[];
|
|
40
|
+
}
|
|
41
|
+
export declare function checkCommand(positional: string[], flags: Map<string, string | boolean>): Promise<number>;
|
|
42
|
+
export declare function buildReadiness(root: string, requested: string): Promise<ReadinessModel>;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { getDiscoveryArtifactContractsForCommand } from "../../../core/src/artifacts/registry.js";
|
|
4
|
+
import { assessStageReadiness } from "../../../core/src/artifacts/readiness.js";
|
|
5
|
+
import { getWorkflowCommands } from "../../../core/src/commands/registry.js";
|
|
6
|
+
import { parseYaml } from "../../../core/src/contracts/yaml.js";
|
|
7
|
+
import { isNotFound, readTextFile } from "../../../core/src/fs/index.js";
|
|
8
|
+
import { evaluateSummaryHealth } from "../../../core/src/workflow/summaryHealth.js";
|
|
9
|
+
import { booleanFlag, stringFlag } from "../args.js";
|
|
10
|
+
import { emptyEffects, printJsonReport } from "../report.js";
|
|
11
|
+
export async function checkCommand(positional, flags) {
|
|
12
|
+
const root = resolve(stringFlag(flags, "root", ".") ?? ".");
|
|
13
|
+
const json = booleanFlag(flags, "json");
|
|
14
|
+
const requested = positional[0];
|
|
15
|
+
if (!requested) {
|
|
16
|
+
const data = missingCommandModel();
|
|
17
|
+
return finish(root, json, data, "Missing command argument.", ["run openworkflow check /ow:vision --root ."]);
|
|
18
|
+
}
|
|
19
|
+
const model = await buildReadiness(root, requested);
|
|
20
|
+
const ok = model.ready;
|
|
21
|
+
const exitCode = model.blockers.length > 0 ? 1 : 0;
|
|
22
|
+
if (json) {
|
|
23
|
+
printJsonReport({
|
|
24
|
+
command: "check",
|
|
25
|
+
ok,
|
|
26
|
+
root,
|
|
27
|
+
data: model,
|
|
28
|
+
warnings: model.warnings,
|
|
29
|
+
errors: model.blockers,
|
|
30
|
+
health_errors: ok ? [] : model.blockers,
|
|
31
|
+
effects: emptyEffects(),
|
|
32
|
+
next_actions: model.next_actions,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
printReadiness(model);
|
|
37
|
+
}
|
|
38
|
+
return exitCode;
|
|
39
|
+
}
|
|
40
|
+
async function finish(root, json, data, error, nextActions) {
|
|
41
|
+
if (json) {
|
|
42
|
+
printJsonReport({
|
|
43
|
+
command: "check",
|
|
44
|
+
ok: false,
|
|
45
|
+
root,
|
|
46
|
+
data,
|
|
47
|
+
warnings: [],
|
|
48
|
+
errors: [error],
|
|
49
|
+
health_errors: [error],
|
|
50
|
+
effects: emptyEffects(),
|
|
51
|
+
next_actions: nextActions,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
console.error(error);
|
|
56
|
+
}
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
export async function buildReadiness(root, requested) {
|
|
60
|
+
const normalized = normalizeCommand(requested);
|
|
61
|
+
const command = findCommand(normalized);
|
|
62
|
+
const currentState = await readCurrentState(root);
|
|
63
|
+
if (!command) {
|
|
64
|
+
return {
|
|
65
|
+
...baseModel(requested, normalized, currentState),
|
|
66
|
+
blockers: [`unknown workflow command: ${requested}`],
|
|
67
|
+
next_actions: ["run openworkflow --help to inspect supported workflow commands"],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const protocol = command.protocol;
|
|
71
|
+
const summaryHealth = await evaluateSummaryHealth(root);
|
|
72
|
+
const required = await contextStatuses(root, protocol?.requiredContext ?? [".openworkflow/workflow/WORKFLOW_INDEX.yaml"]);
|
|
73
|
+
const optional = await contextStatuses(root, protocol?.optionalContext ?? []);
|
|
74
|
+
const forbidden = await contextStatuses(root, protocol?.forbiddenContext ?? []);
|
|
75
|
+
const semanticReadiness = await assessStageReadiness(root, command.trigger, currentState);
|
|
76
|
+
const blockers = [
|
|
77
|
+
...required.filter((item) => !item.exists).map((item) => `missing required context: ${item.path}`),
|
|
78
|
+
...forbidden.filter((item) => item.exists).map((item) => `forbidden context exists: ${item.path}`),
|
|
79
|
+
...semanticReadiness.blockers,
|
|
80
|
+
];
|
|
81
|
+
const warnings = [];
|
|
82
|
+
const nextCommand = stringOrNull(currentState?.next_command);
|
|
83
|
+
if (nextCommand && nextCommand !== command.trigger) {
|
|
84
|
+
warnings.push(`CURRENT_STATE next_command is ${nextCommand}, not ${command.trigger}`);
|
|
85
|
+
}
|
|
86
|
+
if (command.visibility === "internal") {
|
|
87
|
+
warnings.push(`${command.trigger} is an internal command and is not a normal user-facing step`);
|
|
88
|
+
}
|
|
89
|
+
const summaryGuidance = summaryGuidanceFor(command.trigger, summaryHealth.entries);
|
|
90
|
+
warnings.push(...summaryWarnings(summaryGuidance));
|
|
91
|
+
if (!summaryHealth.initialized) {
|
|
92
|
+
warnings.push("summary health unavailable because OpenWorkflow artifact contracts are missing");
|
|
93
|
+
}
|
|
94
|
+
warnings.push(...semanticReadiness.warnings);
|
|
95
|
+
const nextActions = nextActionsFor(command, blockers, warnings, currentState);
|
|
96
|
+
return {
|
|
97
|
+
...baseModel(requested, command.trigger, currentState),
|
|
98
|
+
ready: blockers.length === 0,
|
|
99
|
+
blockers,
|
|
100
|
+
warnings,
|
|
101
|
+
required_context: required,
|
|
102
|
+
optional_context: optional,
|
|
103
|
+
forbidden_context: forbidden,
|
|
104
|
+
conditional_context: protocol?.conditionalOutputs ?? [],
|
|
105
|
+
allowed_outputs: protocol?.allowedOutputs ?? command.targetArtifacts,
|
|
106
|
+
forbidden_outputs: protocol?.forbiddenOutputs ?? [],
|
|
107
|
+
handoff_commands: protocol?.handoffCommands ?? [],
|
|
108
|
+
artifact_contracts: getDiscoveryArtifactContractsForCommand(command.trigger).map((artifact) => ({
|
|
109
|
+
artifact_type: artifact.artifactType,
|
|
110
|
+
source_of_truth_path: artifact.sourceOfTruthPath,
|
|
111
|
+
summary_policy: artifact.summaryPolicy?.strategy ?? null,
|
|
112
|
+
})),
|
|
113
|
+
semantic_readiness: {
|
|
114
|
+
gate_status: semanticReadiness.gate_status ?? null,
|
|
115
|
+
ok: semanticReadiness.ok,
|
|
116
|
+
blockers: semanticReadiness.blockers,
|
|
117
|
+
warnings: semanticReadiness.warnings,
|
|
118
|
+
},
|
|
119
|
+
summary_guidance: summaryGuidance,
|
|
120
|
+
next_actions: nextActions,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function printReadiness(model) {
|
|
124
|
+
console.log(`OpenWorkflow command check: ${model.normalized_command ?? model.command ?? "unknown"}`);
|
|
125
|
+
console.log(`ready: ${model.ready}`);
|
|
126
|
+
printList("blockers", model.blockers);
|
|
127
|
+
printList("warnings", model.warnings);
|
|
128
|
+
printContext("required_context", model.required_context);
|
|
129
|
+
printContext("forbidden_context", model.forbidden_context);
|
|
130
|
+
printList("allowed_outputs", model.allowed_outputs);
|
|
131
|
+
printList("forbidden_outputs", model.forbidden_outputs);
|
|
132
|
+
printList("handoff_commands", model.handoff_commands);
|
|
133
|
+
if (model.semantic_readiness) {
|
|
134
|
+
console.log(`semantic_readiness: ${model.semantic_readiness.gate_status ?? "unknown"}`);
|
|
135
|
+
}
|
|
136
|
+
printList("summary_guidance", model.summary_guidance.map((item) => `${item.artifact_type}: ${item.status}`));
|
|
137
|
+
printList("read_this_first", model.read_this_first);
|
|
138
|
+
printList("next_actions", model.next_actions);
|
|
139
|
+
}
|
|
140
|
+
function printList(label, values) {
|
|
141
|
+
console.log(`${label}:`);
|
|
142
|
+
for (const value of values.length > 0 ? values : ["none"]) {
|
|
143
|
+
console.log(` - ${value}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function printContext(label, values) {
|
|
147
|
+
console.log(`${label}:`);
|
|
148
|
+
for (const value of values.length > 0 ? values : [{ path: "none", exists: false }]) {
|
|
149
|
+
console.log(` - ${value.path} (${value.exists ? "exists" : "missing"})`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function missingCommandModel() {
|
|
153
|
+
return {
|
|
154
|
+
command: null,
|
|
155
|
+
normalized_command: null,
|
|
156
|
+
ready: false,
|
|
157
|
+
blockers: ["missing command argument"],
|
|
158
|
+
warnings: [],
|
|
159
|
+
required_context: [],
|
|
160
|
+
optional_context: [],
|
|
161
|
+
forbidden_context: [],
|
|
162
|
+
conditional_context: [],
|
|
163
|
+
allowed_outputs: [],
|
|
164
|
+
forbidden_outputs: [],
|
|
165
|
+
handoff_commands: [],
|
|
166
|
+
artifact_contracts: [],
|
|
167
|
+
semantic_readiness: null,
|
|
168
|
+
summary_guidance: [],
|
|
169
|
+
read_this_first: [],
|
|
170
|
+
active_pointers: {},
|
|
171
|
+
next_actions: ["run openworkflow check /ow:vision --root ."],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function baseModel(requested, normalized, currentState) {
|
|
175
|
+
return {
|
|
176
|
+
command: requested,
|
|
177
|
+
normalized_command: normalized,
|
|
178
|
+
ready: false,
|
|
179
|
+
blockers: [],
|
|
180
|
+
warnings: [],
|
|
181
|
+
required_context: [],
|
|
182
|
+
optional_context: [],
|
|
183
|
+
forbidden_context: [],
|
|
184
|
+
conditional_context: [],
|
|
185
|
+
allowed_outputs: [],
|
|
186
|
+
forbidden_outputs: [],
|
|
187
|
+
handoff_commands: [],
|
|
188
|
+
artifact_contracts: [],
|
|
189
|
+
semantic_readiness: null,
|
|
190
|
+
summary_guidance: [],
|
|
191
|
+
read_this_first: stringList(currentState?.read_this_first),
|
|
192
|
+
active_pointers: activePointers(currentState),
|
|
193
|
+
next_actions: [],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function summaryGuidanceFor(command, entries) {
|
|
197
|
+
const artifactTypes = new Set(getDiscoveryArtifactContractsForCommand(command).map((artifact) => artifact.artifactType));
|
|
198
|
+
return entries
|
|
199
|
+
.filter((entry) => artifactTypes.has(entry.artifact_type) && entry.strategy !== "none")
|
|
200
|
+
.map((entry) => ({
|
|
201
|
+
artifact_type: entry.artifact_type,
|
|
202
|
+
status: entry.status,
|
|
203
|
+
next_actions: entry.next_actions,
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
function summaryWarnings(guidance) {
|
|
207
|
+
return guidance
|
|
208
|
+
.filter((entry) => entry.status === "missing" || entry.status === "stale_unknown")
|
|
209
|
+
.map((entry) => `summary health for ${entry.artifact_type} is ${entry.status}; inspect summaries before relying on low-context reads`);
|
|
210
|
+
}
|
|
211
|
+
function nextActionsFor(command, blockers, warnings, currentState) {
|
|
212
|
+
if (blockers.length > 0) {
|
|
213
|
+
return ["resolve blockers before starting the workflow command"];
|
|
214
|
+
}
|
|
215
|
+
const nextCommand = stringOrNull(currentState?.next_command);
|
|
216
|
+
if (nextCommand && nextCommand !== command.trigger && warnings.length > 0) {
|
|
217
|
+
return [`consider running ${nextCommand} first, or confirm why ${command.trigger} is appropriate now`];
|
|
218
|
+
}
|
|
219
|
+
return [`start ${command.trigger} using the repo-local Agent skill`];
|
|
220
|
+
}
|
|
221
|
+
async function contextStatuses(root, paths) {
|
|
222
|
+
return Promise.all(paths.map(async (path) => ({ path, exists: await contextExists(root, path) })));
|
|
223
|
+
}
|
|
224
|
+
async function contextExists(root, pattern) {
|
|
225
|
+
const clean = pattern.replace(/<[^>]+>/gu, "");
|
|
226
|
+
if (clean.includes("**")) {
|
|
227
|
+
return existsPrefix(root, clean.split("**", 1)[0] ?? clean);
|
|
228
|
+
}
|
|
229
|
+
if (clean.endsWith("/")) {
|
|
230
|
+
return existsPath(root, clean);
|
|
231
|
+
}
|
|
232
|
+
return existsPath(root, clean);
|
|
233
|
+
}
|
|
234
|
+
async function existsPrefix(root, prefix) {
|
|
235
|
+
const path = join(root, prefix);
|
|
236
|
+
try {
|
|
237
|
+
const info = await stat(path);
|
|
238
|
+
if (info.isFile()) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
if (info.isDirectory()) {
|
|
242
|
+
const entries = await readdir(path);
|
|
243
|
+
return entries.length > 0;
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
if (isNotFound(error)) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async function existsPath(root, relativePath) {
|
|
255
|
+
try {
|
|
256
|
+
await stat(join(root, relativePath));
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (isNotFound(error)) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async function readCurrentState(root) {
|
|
267
|
+
try {
|
|
268
|
+
const data = parseYaml(await readTextFile(join(root, ".openworkflow", "CURRENT_STATE.yaml")));
|
|
269
|
+
return isRecord(data) ? data : null;
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
if (isNotFound(error)) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function normalizeCommand(value) {
|
|
279
|
+
const trimmed = value.trim();
|
|
280
|
+
if (trimmed.startsWith("/ow:")) {
|
|
281
|
+
return trimmed;
|
|
282
|
+
}
|
|
283
|
+
if (trimmed.startsWith("ow:")) {
|
|
284
|
+
return `/${trimmed}`;
|
|
285
|
+
}
|
|
286
|
+
if (trimmed.startsWith("ow-")) {
|
|
287
|
+
return `/ow:${trimmed.slice("ow-".length)}`;
|
|
288
|
+
}
|
|
289
|
+
if (trimmed.startsWith("/")) {
|
|
290
|
+
return trimmed;
|
|
291
|
+
}
|
|
292
|
+
return `/ow:${trimmed}`;
|
|
293
|
+
}
|
|
294
|
+
function findCommand(normalized) {
|
|
295
|
+
return getWorkflowCommands().find((command) => command.trigger === normalized || command.legacyTriggers.includes(normalized));
|
|
296
|
+
}
|
|
297
|
+
function activePointers(currentState) {
|
|
298
|
+
const keys = [
|
|
299
|
+
"current_vision",
|
|
300
|
+
"current_validation",
|
|
301
|
+
"current_prototype",
|
|
302
|
+
"current_decision",
|
|
303
|
+
"current_design",
|
|
304
|
+
"current_spec",
|
|
305
|
+
"current_change",
|
|
306
|
+
"current_run",
|
|
307
|
+
];
|
|
308
|
+
return Object.fromEntries(keys.map((key) => [key, currentPointerValue(currentState, key)]));
|
|
309
|
+
}
|
|
310
|
+
function currentPointerValue(currentState, key) {
|
|
311
|
+
const direct = stringOrNull(currentState?.[key]);
|
|
312
|
+
if (direct || key !== "current_vision") {
|
|
313
|
+
return direct;
|
|
314
|
+
}
|
|
315
|
+
return stringOrNull(currentState?.current_session);
|
|
316
|
+
}
|
|
317
|
+
function stringList(value) {
|
|
318
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
319
|
+
}
|
|
320
|
+
function stringOrNull(value) {
|
|
321
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
322
|
+
}
|
|
323
|
+
function isRecord(value) {
|
|
324
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=check.js.map
|