@tiic-tech/openworkflow 0.1.1 → 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/dist/adapters/codex/src/cleanCodexAdapter.js +4 -1
- package/dist/adapters/codex/src/cleanCodexAdapter.js.map +1 -1
- 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.js +46 -1
- package/dist/cli/src/commands/clean.js.map +1 -1
- 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.js +213 -2
- package/dist/cli/src/dev/verifyCleanCommand.js.map +1 -1
- 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 +184 -6
- 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 +2321 -306
- package/dist/core/src/validators/validateRepositoryContracts.js.map +1 -1
- package/dist/core/src/workflow/cleanOpenWorkflow.d.ts +2 -0
- package/dist/core/src/workflow/cleanOpenWorkflow.js +97 -8
- package/dist/core/src/workflow/cleanOpenWorkflow.js.map +1 -1
- 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 +2 -1
- 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,164 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { isNotFound, readTextFile } from "../fs/index.js";
|
|
4
|
+
export const AGENTS_GUIDE_PATH = "AGENTS.md";
|
|
5
|
+
export const AGENTS_GUIDE_TEMPLATE_ID = "openworkflow.agents-guide.v1";
|
|
6
|
+
export const AGENTS_GUIDE_BEGIN = `<!-- BEGIN OPENWORKFLOW AGENT GUIDE generated-by: openworkflow; template-id: ${AGENTS_GUIDE_TEMPLATE_ID} -->`;
|
|
7
|
+
export const AGENTS_GUIDE_END = "<!-- END OPENWORKFLOW AGENT GUIDE -->";
|
|
8
|
+
export function renderAgentsGuide() {
|
|
9
|
+
return `${AGENTS_GUIDE_BEGIN}
|
|
10
|
+
## OpenWorkflow
|
|
11
|
+
|
|
12
|
+
- Run \`openworkflow --help\` first when you need current CLI capabilities, workflow command boundaries, or maintenance commands.
|
|
13
|
+
- Prefer \`--json\` for structured command output; every OpenWorkflow CLI command supports a JSON report envelope for Agent consumption.
|
|
14
|
+
- Treat JSON \`ok:false\` as a failed command: OpenWorkflow exits nonzero but still writes the parseable JSON report to stdout. Read \`health_errors\` for blocking health/readiness failures, \`errors\` for command/runtime failures, and \`warnings\` for non-blocking guidance.
|
|
15
|
+
- Use \`openworkflow resume --root . --json\` as the first recovery command when a fresh Agent is asked to continue after network loss, context overflow, compaction failure, or unexpected termination. Resume is the minimal-context precision entrypoint for project overview, current queue/work item, breakpoint, behavior boundaries, allowed work, validation expectations, git state, and the smallest correct OW-maintained next action.
|
|
16
|
+
- Run \`openworkflow handoff --root . --json\` as the strict Agent trust gate before loading context; it aggregates managed surface health, strict summary quality, current pointers, next-command readiness, read order, blockers, and next actions.
|
|
17
|
+
- Use \`openworkflow context --root . --handoff --json\` when you need both a bounded startup packet and strict handoff-quality blocking in one command; default \`context --json\` remains packet-only and may return \`ok:true\` with handoff warnings.
|
|
18
|
+
- Start with \`openworkflow inspect --root . --json\` for the aggregated Agent entry read model, health, next-command readiness, and read order; add \`--strict\` when current-but-thin summary quality should block handoff trust.
|
|
19
|
+
- Treat \`openworkflow doctor --root . --json\` as a managed-surface maintenance check; its top-level \`ok\` does not prove artifact handoff quality. Read \`handoff_quality_ok\` or use \`inspect --strict\` / \`summaries --strict\` for handoff gates.
|
|
20
|
+
- Start every workflow turn by reading \`.openworkflow/CURRENT_STATE.yaml\`, then follow its \`read_this_first\` pointers before loading full evidence.
|
|
21
|
+
- When dogfooding OpenWorkflow inside its own repository, use OpenWorkflow commands as the read model and trust gate before implementation, but make durable product changes in the source files that generate the managed surfaces.
|
|
22
|
+
- Treat each \`decompose-to-changes\` \`CANDIDATE_CHANGES.yaml\` queue as the feat boundary. Create one top-level \`changes/<feat-id>/\` folder for that queue, then treat each selected candidate inside it as a commit-sized change with selection, atom-task, and brief artifacts kept under the feat folder.
|
|
23
|
+
- Do not create a new top-level feat folder for every small candidate. Open a new top-level \`changes/<feat-id>/\` only when a new decomposition queue or product theme is needed; otherwise advance the current feat through focused commits.
|
|
24
|
+
- Do not manually patch generated or managed surfaces such as \`.openworkflow/**\`, \`.agents/skills/ow-*/SKILL.md\`, or \`AGENTS.md\` to fix product behavior; update the registry, artifact contracts, templates, schemas, or tests that produce them, then run \`openworkflow sync\` or \`init\` to regenerate.
|
|
25
|
+
- CLI commands maintain and summarize the repo-local workflow surface: \`init\`, \`sync\`, \`validate\`, \`doctor\`, \`handoff\`, \`resume\`, \`inspect\`, \`context\`, \`draft\`, \`register\`, \`status\`, \`brief\`, \`check\`, \`summaries\`, and \`clean\`.
|
|
26
|
+
- Use \`resume --json\` for interrupted-session recovery. Use \`handoff --json\` when you only need the strict trust gate, \`context --json\` when you need a bounded packet for a known \`/ow:*\` command, \`inspect --json\` when you need the aggregated read model and read order, and \`status\` or \`brief\` when you need a lightweight state summary. Do not treat resume as a generic autonomous retry loop; it should route the Agent into corrected, ranked atom-task continuation with explicit product-alignment and stop boundaries.
|
|
27
|
+
- Use \`openworkflow context --root . --json\` to materialize a compact startup packet for \`CURRENT_STATE.next_command\`; compact mode returns a structured \`command_audit\` slice instead of full audit source. Add \`--handoff\` when thin or stale summaries should make the packet fail, and add \`--for /ow:<command>\`, \`--max-bytes <n>\`, or \`--mode full\` when you need a specific workflow command, tighter budget, or full managed audit source.
|
|
28
|
+
- In \`context --json\` and \`doctor --json\`, read \`data.handoff_quality_ok\` and \`data.quality_summary\` before trusting low-context handoff artifacts; \`quality_summary.status\` tells you whether summaries are trusted, need refresh, or are current-but-thin.
|
|
29
|
+
- Use \`openworkflow draft --root . --artifact <type> --id <id> --json\` to preview a contract-shaped source artifact; add \`--write\` only when the active \`/ow:*\` workflow step should create that artifact.
|
|
30
|
+
- Use \`openworkflow register --root . --artifact <path> --json\` after a source artifact exists to preview index registration; add \`--write\` to make it visible to read models, and \`--current\` only when it should become the active pointer.
|
|
31
|
+
- Use \`openworkflow brief --root .\` or \`openworkflow status --root .\` for a low-context Agent read model before deciding what to inspect next; use \`--json\` when another tool needs structured data.
|
|
32
|
+
- Use \`openworkflow check /ow:<command> --root . --json\` before uncertain workflow work to verify required context, forbidden context, output boundaries, current artifact usability, and next actions.
|
|
33
|
+
- Use \`openworkflow summaries --root . --json\` before loading raw evidence when artifact summaries or current slices may be missing, stale, or current-but-thin; add \`--strict\` to make draft/thin source quality return \`ok:false\`. Freshness and source artifact quality are separate signals.
|
|
34
|
+
- Use \`openworkflow summarize --root . --artifact <path> --json\` to preview SUMMARY.yaml refreshes; add \`--write\` only when you intend to update summary files without changing source artifacts.
|
|
35
|
+
- Use \`openworkflow validate --root . --json\` for contract shape; SUMMARY.yaml trust is checked by \`summaries\`, not by \`validate\`.
|
|
36
|
+
- Use \`openworkflow clean --root . --tools codex --json\` to preview managed/generated cleanup; \`--yes\` removes OpenWorkflow managed metadata and generated adapter files while preserving source artifacts, SUMMARY.yaml, evidence, notes, and user AGENTS.md content.
|
|
37
|
+
- Repo-local workflow commands are delivered as Agent skills under \`.agents/skills/ow-*/SKILL.md\` and map to semantic commands: \`/ow:vision\`, \`/ow:validation\`, \`/ow:proto\`, \`/ow:tune\`, \`/ow:design\`, \`/ow:spec\`, \`/ow:change\`, \`/ow:team\`, \`/ow:decompose-to-changes\`, \`/ow:analyze-changes\`, \`/ow:select-change\`, and \`/ow:git-automation\`.
|
|
38
|
+
- Respect lazy creation: \`openworkflow init\` only creates the minimal workflow root; stage artifacts must be created only by the first matching \`/ow:*\` command.
|
|
39
|
+
- Project-local \`SOUL.md\` and \`MEMORY.md\` are future governed learning artifacts. Do not conflate them with the resume packet; resume may surface trusted signals later, but it does not create or evolve persistent project personality or memory.
|
|
40
|
+
- Prefer summary/current-state files for orientation, and load raw evidence only when the current task requires it.
|
|
41
|
+
${AGENTS_GUIDE_END}
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
export async function syncAgentsGuide(root) {
|
|
45
|
+
const path = join(root, AGENTS_GUIDE_PATH);
|
|
46
|
+
const existing = await readOptional(path);
|
|
47
|
+
const next = upsertAgentsGuide(existing);
|
|
48
|
+
if (!next.changed) {
|
|
49
|
+
return { path, action: "unchanged" };
|
|
50
|
+
}
|
|
51
|
+
await mkdir(dirname(path), { recursive: true });
|
|
52
|
+
await writeFile(path, next.content, "utf8");
|
|
53
|
+
return { path, action: next.action };
|
|
54
|
+
}
|
|
55
|
+
export async function doctorAgentsGuide(root) {
|
|
56
|
+
const path = join(root, AGENTS_GUIDE_PATH);
|
|
57
|
+
const content = await readOptional(path);
|
|
58
|
+
if (content === null) {
|
|
59
|
+
return {
|
|
60
|
+
ok: true,
|
|
61
|
+
warnings: [`${AGENTS_GUIDE_PATH} is missing; run openworkflow sync to create the Agent onboarding guide.`],
|
|
62
|
+
errors: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (!hasAgentsGuide(content)) {
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
warnings: [`${AGENTS_GUIDE_PATH} has no OpenWorkflow managed block; run openworkflow sync to append it without changing existing content.`],
|
|
69
|
+
errors: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (!isAgentsGuideCurrent(content)) {
|
|
73
|
+
return {
|
|
74
|
+
ok: true,
|
|
75
|
+
warnings: [`${AGENTS_GUIDE_PATH} OpenWorkflow managed block is stale; run openworkflow sync to refresh it.`],
|
|
76
|
+
errors: [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return { ok: true, warnings: [], errors: [] };
|
|
80
|
+
}
|
|
81
|
+
export async function cleanAgentsGuide(options) {
|
|
82
|
+
const dryRun = !options.yes;
|
|
83
|
+
const path = join(options.root, AGENTS_GUIDE_PATH);
|
|
84
|
+
const planned = [];
|
|
85
|
+
const removed = [];
|
|
86
|
+
const updated = [];
|
|
87
|
+
const skipped = [];
|
|
88
|
+
const preserved = [];
|
|
89
|
+
const warnings = [];
|
|
90
|
+
const content = await readOptional(path);
|
|
91
|
+
if (content === null || !hasAgentsGuide(content)) {
|
|
92
|
+
return { planned, removed, updated, skipped, preserved, warnings, dryRun };
|
|
93
|
+
}
|
|
94
|
+
planned.push({ path, reason: "OpenWorkflow AGENTS.md managed block" });
|
|
95
|
+
if (dryRun) {
|
|
96
|
+
return { planned, removed, updated, skipped, preserved, warnings, dryRun };
|
|
97
|
+
}
|
|
98
|
+
const next = removeAgentsGuide(content);
|
|
99
|
+
if (!next.changed) {
|
|
100
|
+
return { planned, removed, updated, skipped, preserved, warnings, dryRun };
|
|
101
|
+
}
|
|
102
|
+
await writeFile(path, next.content, "utf8");
|
|
103
|
+
updated.push(path);
|
|
104
|
+
preserved.push(path);
|
|
105
|
+
return { planned, removed, updated, skipped, preserved, warnings, dryRun };
|
|
106
|
+
}
|
|
107
|
+
export function hasAgentsGuide(content) {
|
|
108
|
+
return content.includes(AGENTS_GUIDE_BEGIN) && content.includes(AGENTS_GUIDE_END);
|
|
109
|
+
}
|
|
110
|
+
export function isAgentsGuideCurrent(content) {
|
|
111
|
+
return hasAgentsGuide(content) && replaceAgentsGuideBlock(content, renderAgentsGuide()) === normalizeFinalNewline(content);
|
|
112
|
+
}
|
|
113
|
+
export function upsertAgentsGuide(existing) {
|
|
114
|
+
const guide = renderAgentsGuide();
|
|
115
|
+
if (existing === null || existing.trim() === "") {
|
|
116
|
+
return { content: guide, changed: true, action: "created" };
|
|
117
|
+
}
|
|
118
|
+
if (hasAgentsGuide(existing)) {
|
|
119
|
+
const content = replaceAgentsGuideBlock(existing, guide);
|
|
120
|
+
if (content === normalizeFinalNewline(existing)) {
|
|
121
|
+
return { content, changed: false, action: "unchanged" };
|
|
122
|
+
}
|
|
123
|
+
return { content, changed: true, action: "updated" };
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
content: `${existing.replace(/\s+$/u, "")}\n\n${guide}`,
|
|
127
|
+
changed: true,
|
|
128
|
+
action: "appended",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function removeAgentsGuide(existing) {
|
|
132
|
+
if (!hasAgentsGuide(existing)) {
|
|
133
|
+
return { content: existing, changed: false };
|
|
134
|
+
}
|
|
135
|
+
const content = existing.replace(blockPattern(), "").replace(/\n{3,}/gu, "\n\n").trim();
|
|
136
|
+
return {
|
|
137
|
+
content: content.length > 0 ? `${content}\n` : "",
|
|
138
|
+
changed: true,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async function readOptional(path) {
|
|
142
|
+
try {
|
|
143
|
+
return await readTextFile(path);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (isNotFound(error)) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function replaceAgentsGuideBlock(content, replacement) {
|
|
153
|
+
return normalizeFinalNewline(content.replace(blockPattern(), replacement.trimEnd()));
|
|
154
|
+
}
|
|
155
|
+
function blockPattern() {
|
|
156
|
+
return new RegExp(`${escapeRegExp(AGENTS_GUIDE_BEGIN)}[\\s\\S]*?${escapeRegExp(AGENTS_GUIDE_END)}\\n?`, "u");
|
|
157
|
+
}
|
|
158
|
+
function normalizeFinalNewline(content) {
|
|
159
|
+
return content.endsWith("\n") ? content : `${content}\n`;
|
|
160
|
+
}
|
|
161
|
+
function escapeRegExp(value) {
|
|
162
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=agentsGuide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentsGuide.js","sourceRoot":"","sources":["../../../../packages/core/src/onboarding/agentsGuide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAC7C,MAAM,CAAC,MAAM,wBAAwB,GAAG,8BAA8B,CAAC;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,gFAAgF,wBAAwB,MAAM,CAAC;AACjJ,MAAM,CAAC,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AAaxE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,GAAG,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgC5B,gBAAgB;CACjB,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACvC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