@structured-vibe-coding/core 0.6.2 → 0.8.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.
@@ -6,17 +6,20 @@ import {
6
6
  PROTOCOL_MD,
7
7
  SDD_AGENT_ROLES,
8
8
  agentHostPaths,
9
+ agentKickoffMessage,
9
10
  getIntegration,
10
11
  installAgentIntegration,
11
12
  installAgentIntegrations,
12
13
  integrationKeyFor,
14
+ loadInstalledAgent,
13
15
  optionForTarget,
14
16
  parseAgentTargets,
15
17
  parseIntegration,
16
18
  refreshActiveAgentContext,
17
19
  removeOtherAgentHosts,
18
- renderThinAgent
19
- } from "./chunk-74AHVIH4.js";
20
+ renderThinAgent,
21
+ writeAgentHandoff
22
+ } from "./chunk-AIFRZY2E.js";
20
23
  export {
21
24
  AGENT_INTEGRATIONS,
22
25
  AGENT_TARGET_OPTIONS,
@@ -25,14 +28,17 @@ export {
25
28
  PROTOCOL_MD,
26
29
  SDD_AGENT_ROLES,
27
30
  agentHostPaths,
31
+ agentKickoffMessage,
28
32
  getIntegration,
29
33
  installAgentIntegration,
30
34
  installAgentIntegrations,
31
35
  integrationKeyFor,
36
+ loadInstalledAgent,
32
37
  optionForTarget,
33
38
  parseAgentTargets,
34
39
  parseIntegration,
35
40
  refreshActiveAgentContext,
36
41
  removeOtherAgentHosts,
37
- renderThinAgent
42
+ renderThinAgent,
43
+ writeAgentHandoff
38
44
  };
@@ -896,6 +896,48 @@ Remind the human: \`sdd verify\` then \`sdd next\` / \`sdd complete\` as appropr
896
896
  Do not claim the change is complete without local verification when the workflow requires it.
897
897
  `;
898
898
  }
899
+ async function loadInstalledAgent(projectRoot) {
900
+ const path = join4(sddRoot(projectRoot), "agents.json");
901
+ if (!await pathExists(path)) return null;
902
+ try {
903
+ const raw = JSON.parse(await readText(path));
904
+ const key = raw.ai ?? raw.integration ?? raw.installed?.[0];
905
+ if (!key || typeof key !== "string") return null;
906
+ const target = parseIntegration(key);
907
+ return { ai: integrationKeyFor(target), target, integration: getIntegration(target) };
908
+ } catch {
909
+ return null;
910
+ }
911
+ }
912
+ async function writeAgentHandoff(projectRoot, config, changeId) {
913
+ const ctx = await buildContext(projectRoot, config, changeId);
914
+ const body = await buildAgentPrompt(ctx, config, projectRoot);
915
+ const outPath = join4(sddRoot(projectRoot), "handoff.md");
916
+ const header = `# SDD handoff (auto)
917
+
918
+ > Generated for the AI coding agent configured at init.
919
+ > Change: **${ctx.meta.title}** \xB7 \`${ctx.id}\` \xB7 stage **${ctx.meta.stage}**
920
+
921
+ Also read: \`.sdd/active-context.md\`, \`.sdd/protocol.md\`, \`memory/constitution.md\` if present.
922
+
923
+ ---
924
+
925
+ `;
926
+ await writeText(outPath, header + body + "\n");
927
+ return outPath;
928
+ }
929
+ function agentKickoffMessage(opts) {
930
+ const event = opts.event ?? "context updated";
931
+ return [
932
+ `SDD: ${event}.`,
933
+ `Title: ${opts.title}`,
934
+ `Change: ${opts.changeId}`,
935
+ `Stage: ${opts.stage}`,
936
+ `Read in order: .sdd/active-context.md, .sdd/handoff.md, .sdd/protocol.md, memory/constitution.md (if present).`,
937
+ `Do the work for the current stage only under changes/${opts.changeId}/. Do not expand scope.`,
938
+ `When the stage is done, tell the human to run: sdd next (or sdd verify / sdd complete as appropriate).`
939
+ ].join(" ");
940
+ }
899
941
  async function refreshActiveAgentContext(projectRoot) {
900
942
  const markerDir = sddRoot(projectRoot);
901
943
  if (!await pathExists(join4(markerDir, "config.yaml"))) {
@@ -1091,6 +1133,9 @@ export {
1091
1133
  installAgentIntegration,
1092
1134
  installAgentIntegrations,
1093
1135
  renderThinAgent,
1136
+ loadInstalledAgent,
1137
+ writeAgentHandoff,
1138
+ agentKickoffMessage,
1094
1139
  refreshActiveAgentContext,
1095
1140
  PROTOCOL_MD
1096
1141
  };
package/dist/index.d.ts CHANGED
@@ -1258,6 +1258,27 @@ declare function installAgentIntegration(opts: InstallAgentOptions): Promise<Ins
1258
1258
  declare function installAgentIntegrations(opts: InstallAgentsOptions): Promise<InstallAgentsResult>;
1259
1259
  /** Thin agent body shared across hosts (same text). */
1260
1260
  declare function renderThinAgent(role: SddAgentRole): string;
1261
+ interface InstalledAgentSnapshot {
1262
+ /** Public key: copilot | claude | grok */
1263
+ ai: string;
1264
+ target: AgentTarget;
1265
+ integration: AgentIntegration;
1266
+ }
1267
+ /** Read which AI agent was configured at `sdd init` / last agents install. */
1268
+ declare function loadInstalledAgent(projectRoot: string): Promise<InstalledAgentSnapshot | null>;
1269
+ /**
1270
+ * Write `.sdd/handoff.md` for the active (or given) change — full agent brief.
1271
+ * Used by `sdd agent` and auto-launch after `sdd new`.
1272
+ */
1273
+ declare function writeAgentHandoff(projectRoot: string, config: Config, changeId: string): Promise<string>;
1274
+ /** Short kickoff line to pass into agent CLIs (full brief is in handoff.md). */
1275
+ declare function agentKickoffMessage(opts: {
1276
+ title: string;
1277
+ stage: string;
1278
+ changeId: string;
1279
+ /** What just happened, e.g. "new change", "advanced to implement" */
1280
+ event?: string;
1281
+ }): string;
1261
1282
  /** Write .sdd/active-context.md for the current change. */
1262
1283
  declare function refreshActiveAgentContext(projectRoot: string): Promise<string | null>;
1263
1284
  /** Single playbook — only long agent-facing content we author once. */
@@ -1329,4 +1350,4 @@ declare function listFiles(path: string): Promise<string[]>;
1329
1350
  declare function copyDir(src: string, dest: string): Promise<void>;
1330
1351
  declare function removePath(path: string): Promise<void>;
1331
1352
 
1332
- export { AGENT_INTEGRATIONS, AGENT_TARGET_OPTIONS, ALL_AGENT_TARGETS, type AdvanceResult, type AgentIntegration, type AgentTarget, type AgentTargetOption, type ArtifactDef, ArtifactDefSchema, type ChangeContext, type ChangeMeta, ChangeMetaSchema, type Complexity, type Config, ConfigSchema, type CreateChangeInput, DEFAULT_INIT_INTEGRATION, type Gate, GateSchema, type InitOptions, type InitResult, type InstallAgentOptions, type InstallAgentResult, type InstallAgentsOptions, type InstallAgentsResult, PROTOCOL_MD, SDD_AGENT_ROLES, SDD_DIR, type SddAgentRole, type SddAgentRoleId, type Stage, StageSchema, VerifyCommandSchema, type VerifyResult, type Workflow, WorkflowSchema, activePointerPath, activeStages, advanceStage, agentHostPaths, approveGate, archiveDir, buildAgentPrompt, buildContext, canLeaveStage, changeDirName, changeMetaPath, changePath, changesDir, clearActiveIf, completeChange, configPath, copyDir, createChange, defaultConfig, defaultMemoryDir, defaultTemplatesDir, defaultWorkflowsDir, defaultsRoot, domainsDir, ensureDir, firstActiveStageId, formatStatus, getActiveChangeId, getIntegration, getStage, inferComplexity, initProject, installAgentIntegration, installAgentIntegrations, integrationKeyFor, isInitialized, isStageSkipped, listChanges, listDirs, listFiles, listWorkflowNames, loadChangeMeta, loadConfig, loadWorkflow, memoryDir, nextStageId, nowIso, optionForTarget, parseAgentTargets, parseIntegration, pathExists, readText, readYaml, recommendWorkflow, refreshActiveAgentContext, removeOtherAgentHosts, removePath, renderThinAgent, resolveChangeId, resolveStages, runLocalVerify, saveChangeMeta, saveConfig, sddRoot, setActiveChange, shouldAutoSkip, skipStage, slugify, switchWorkflow, templatesDir, todayIsoDate, uniqueChangeDirName, workflowsDir, writeText, writeYaml };
1353
+ export { AGENT_INTEGRATIONS, AGENT_TARGET_OPTIONS, ALL_AGENT_TARGETS, type AdvanceResult, type AgentIntegration, type AgentTarget, type AgentTargetOption, type ArtifactDef, ArtifactDefSchema, type ChangeContext, type ChangeMeta, ChangeMetaSchema, type Complexity, type Config, ConfigSchema, type CreateChangeInput, DEFAULT_INIT_INTEGRATION, type Gate, GateSchema, type InitOptions, type InitResult, type InstallAgentOptions, type InstallAgentResult, type InstallAgentsOptions, type InstallAgentsResult, type InstalledAgentSnapshot, PROTOCOL_MD, SDD_AGENT_ROLES, SDD_DIR, type SddAgentRole, type SddAgentRoleId, type Stage, StageSchema, VerifyCommandSchema, type VerifyResult, type Workflow, WorkflowSchema, activePointerPath, activeStages, advanceStage, agentHostPaths, agentKickoffMessage, approveGate, archiveDir, buildAgentPrompt, buildContext, canLeaveStage, changeDirName, changeMetaPath, changePath, changesDir, clearActiveIf, completeChange, configPath, copyDir, createChange, defaultConfig, defaultMemoryDir, defaultTemplatesDir, defaultWorkflowsDir, defaultsRoot, domainsDir, ensureDir, firstActiveStageId, formatStatus, getActiveChangeId, getIntegration, getStage, inferComplexity, initProject, installAgentIntegration, installAgentIntegrations, integrationKeyFor, isInitialized, isStageSkipped, listChanges, listDirs, listFiles, listWorkflowNames, loadChangeMeta, loadConfig, loadInstalledAgent, loadWorkflow, memoryDir, nextStageId, nowIso, optionForTarget, parseAgentTargets, parseIntegration, pathExists, readText, readYaml, recommendWorkflow, refreshActiveAgentContext, removeOtherAgentHosts, removePath, renderThinAgent, resolveChangeId, resolveStages, runLocalVerify, saveChangeMeta, saveConfig, sddRoot, setActiveChange, shouldAutoSkip, skipStage, slugify, switchWorkflow, templatesDir, todayIsoDate, uniqueChangeDirName, workflowsDir, writeAgentHandoff, writeText, writeYaml };
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  activePointerPath,
17
17
  activeStages,
18
18
  agentHostPaths,
19
+ agentKickoffMessage,
19
20
  archiveDir,
20
21
  buildAgentPrompt,
21
22
  buildContext,
@@ -46,6 +47,7 @@ import {
46
47
  listWorkflowNames,
47
48
  loadChangeMeta,
48
49
  loadConfig,
50
+ loadInstalledAgent,
49
51
  loadWorkflow,
50
52
  memoryDir,
51
53
  nextStageId,
@@ -73,9 +75,10 @@ import {
73
75
  todayIsoDate,
74
76
  uniqueChangeDirName,
75
77
  workflowsDir,
78
+ writeAgentHandoff,
76
79
  writeText,
77
80
  writeYaml
78
- } from "./chunk-74AHVIH4.js";
81
+ } from "./chunk-AIFRZY2E.js";
79
82
 
80
83
  // src/change.ts
81
84
  import { join as join2 } from "pathe";
@@ -187,7 +190,7 @@ async function createChange(input) {
187
190
  await materializeStageArtifacts(projectRoot, config, id, workflow, meta, firstStage);
188
191
  await setActiveChange(projectRoot, config, id);
189
192
  try {
190
- const { refreshActiveAgentContext: refreshActiveAgentContext2 } = await import("./agents-TYGI6EX3.js");
193
+ const { refreshActiveAgentContext: refreshActiveAgentContext2 } = await import("./agents-UCNZSN5M.js");
191
194
  await refreshActiveAgentContext2(projectRoot);
192
195
  } catch {
193
196
  }
@@ -283,7 +286,7 @@ async function advanceStage(projectRoot, config, changeId, opts) {
283
286
  stage
284
287
  );
285
288
  try {
286
- const { refreshActiveAgentContext: refreshActiveAgentContext2 } = await import("./agents-TYGI6EX3.js");
289
+ const { refreshActiveAgentContext: refreshActiveAgentContext2 } = await import("./agents-UCNZSN5M.js");
287
290
  await refreshActiveAgentContext2(projectRoot);
288
291
  } catch {
289
292
  }
@@ -711,6 +714,7 @@ export {
711
714
  activeStages,
712
715
  advanceStage,
713
716
  agentHostPaths,
717
+ agentKickoffMessage,
714
718
  approveGate,
715
719
  archiveDir,
716
720
  buildAgentPrompt,
@@ -750,6 +754,7 @@ export {
750
754
  listWorkflowNames,
751
755
  loadChangeMeta,
752
756
  loadConfig,
757
+ loadInstalledAgent,
753
758
  loadWorkflow,
754
759
  memoryDir,
755
760
  nextStageId,
@@ -780,6 +785,7 @@ export {
780
785
  todayIsoDate,
781
786
  uniqueChangeDirName,
782
787
  workflowsDir,
788
+ writeAgentHandoff,
783
789
  writeText,
784
790
  writeYaml
785
791
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@structured-vibe-coding/core",
3
- "version": "0.6.2",
3
+ "version": "0.8.0",
4
4
  "description": "Core engine for structured vibe coding (local-first Spec-Driven Development)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",