@structured-vibe-coding/core 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ import {
2
+ getStage,
3
+ isStageSkipped,
4
+ shouldAutoSkip
5
+ } from "./chunk-A752UVPF.js";
6
+
7
+ // src/agent-handoff.ts
8
+ import { join } from "pathe";
9
+ function formatStatus(ctx) {
10
+ const lines = [];
11
+ lines.push(`Change: ${ctx.meta.title}`);
12
+ lines.push(`ID: ${ctx.id}`);
13
+ lines.push(`Status: ${ctx.meta.status}`);
14
+ lines.push(`Workflow: ${ctx.meta.workflow}`);
15
+ lines.push(`Path: ${ctx.path}`);
16
+ lines.push("");
17
+ lines.push("Stages:");
18
+ for (const stage of ctx.stages) {
19
+ const skipped = isStageSkipped(ctx.meta, stage.id) || shouldAutoSkip(stage, ctx.meta);
20
+ let mark = " ";
21
+ if (skipped) mark = "\xB7";
22
+ else if (stage.id === ctx.meta.stage) mark = "\u25CF";
23
+ else {
24
+ const order = ctx.active.map((s) => s.id);
25
+ const cur = order.indexOf(ctx.meta.stage);
26
+ const idx = order.indexOf(stage.id);
27
+ if (idx >= 0 && cur >= 0 && idx < cur) mark = "\u2713";
28
+ }
29
+ const gate = ctx.meta.gates?.[stage.id];
30
+ const gateInfo = gate ? ` [${gate.status}]` : "";
31
+ const skipInfo = skipped ? " (skipped)" : "";
32
+ lines.push(
33
+ ` [${mark}] ${stage.id}${stage.title ? ` \u2014 ${stage.title}` : ""}${gateInfo}${skipInfo}`
34
+ );
35
+ }
36
+ if (ctx.meta.overrides?.skip_stages?.length) {
37
+ lines.push("");
38
+ lines.push(`Overrides: skip=${ctx.meta.overrides.skip_stages.join(", ")}`);
39
+ }
40
+ return lines.join("\n");
41
+ }
42
+ async function buildAgentPrompt(ctx, config, projectRoot) {
43
+ const stage = getStage(ctx.workflow, ctx.meta, ctx.meta.stage);
44
+ const parts = [];
45
+ parts.push(`# SDD Agent Handoff`);
46
+ parts.push("");
47
+ parts.push(`You are implementing a change under Structured Vibe Coding (local SDD).`);
48
+ parts.push("");
49
+ parts.push(`## Change`);
50
+ parts.push(`- Title: ${ctx.meta.title}`);
51
+ parts.push(`- ID: ${ctx.id}`);
52
+ parts.push(`- Workflow: ${ctx.meta.workflow}`);
53
+ parts.push(
54
+ `- Current stage: ${ctx.meta.stage}${stage?.title ? ` (${stage.title})` : ""}`
55
+ );
56
+ parts.push(`- Change path: ${ctx.path}`);
57
+ parts.push("");
58
+ if (stage?.summary) {
59
+ parts.push(`## Stage goal`);
60
+ parts.push(stage.summary);
61
+ parts.push("");
62
+ }
63
+ if (stage?.agent_context?.instructions) {
64
+ parts.push(`## Instructions`);
65
+ parts.push(stage.agent_context.instructions);
66
+ parts.push("");
67
+ }
68
+ parts.push(`## Constraints`);
69
+ parts.push(`- Follow artifacts in the change directory as source of truth.`);
70
+ parts.push(`- Honor \`memory/constitution.md\` when present (non-negotiables).`);
71
+ parts.push(`- Do not skip ARB/decision constraints if present.`);
72
+ parts.push(`- Local development only \u2014 verify on this machine.`);
73
+ parts.push(`- Prefer small, reviewable commits.`);
74
+ parts.push("");
75
+ parts.push(`## Artifacts to read`);
76
+ const memoryHint = join(projectRoot, config.memory_path);
77
+ parts.push(`- Documentation map (if present): ${memoryHint}/index.md`);
78
+ parts.push(`- Memory: ${memoryHint}/`);
79
+ for (const s of ctx.stages) {
80
+ for (const a of s.artifacts) {
81
+ parts.push(`- ${join(ctx.path, a.path)}`);
82
+ }
83
+ }
84
+ parts.push("");
85
+ parts.push(`## Current stage artifacts`);
86
+ if (stage) {
87
+ for (const a of stage.artifacts) {
88
+ parts.push(`- ${a.path}${a.required ? " (required)" : ""}`);
89
+ }
90
+ }
91
+ parts.push("");
92
+ const stageId = ctx.meta.stage;
93
+ if (stageId === "implement" || stageId === "local_verify") {
94
+ parts.push(`## Code context (product code)`);
95
+ parts.push("");
96
+ parts.push(
97
+ `Process context above is not enough for product code structure.`
98
+ );
99
+ parts.push(
100
+ `When you need symbols, callers, or package-boundary context:`
101
+ );
102
+ parts.push(
103
+ `1. Run: \`sdd context\` (optional: \`--path \u2026\`, \`--symbol \u2026\`, \`--out change\`)`
104
+ );
105
+ parts.push(
106
+ `2. If present, read: \`changes/${ctx.id}/code-context.md\` (regenerate if stale)`
107
+ );
108
+ parts.push(
109
+ `Do not dump unbounded source into the prompt; prefer the sliced output.`
110
+ );
111
+ parts.push("");
112
+ }
113
+ parts.push(
114
+ `When done with this stage, the human will run \`sdd next\` or \`sdd verify\` / \`sdd complete\`.`
115
+ );
116
+ return parts.join("\n");
117
+ }
118
+
119
+ export {
120
+ formatStatus,
121
+ buildAgentPrompt
122
+ };
@@ -0,0 +1,42 @@
1
+ import {
2
+ ConfigSchema
3
+ } from "./chunk-67AUAGNV.js";
4
+ import {
5
+ configPath,
6
+ sddRoot
7
+ } from "./chunk-7MJYPJMR.js";
8
+ import {
9
+ ensureDir,
10
+ pathExists,
11
+ readYaml,
12
+ writeYaml
13
+ } from "./chunk-EPFURATC.js";
14
+
15
+ // src/config.ts
16
+ async function isInitialized(projectRoot) {
17
+ return pathExists(configPath(projectRoot));
18
+ }
19
+ async function loadConfig(projectRoot) {
20
+ const path = configPath(projectRoot);
21
+ if (!await pathExists(path)) {
22
+ throw new Error(
23
+ `SDD is not initialized in ${projectRoot}. Run \`sdd init\` first.`
24
+ );
25
+ }
26
+ const raw = await readYaml(path);
27
+ return ConfigSchema.parse(raw);
28
+ }
29
+ async function saveConfig(projectRoot, config) {
30
+ await ensureDir(sddRoot(projectRoot));
31
+ await writeYaml(configPath(projectRoot), ConfigSchema.parse(config));
32
+ }
33
+ function defaultConfig() {
34
+ return ConfigSchema.parse({});
35
+ }
36
+
37
+ export {
38
+ isInitialized,
39
+ loadConfig,
40
+ saveConfig,
41
+ defaultConfig
42
+ };