@structured-vibe-coding/core 0.9.0 → 0.10.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.
- package/README.md +1 -4
- package/dist/{agents-BA7WVN35.js → agents-IB37YJX6.js} +4 -1
- package/dist/chunk-7MJYPJMR.js +51 -0
- package/dist/chunk-EPFURATC.js +96 -0
- package/dist/chunk-KZHNYGD6.js +187 -0
- package/dist/{chunk-M245MC6E.js → chunk-UAOFNSLQ.js} +74 -335
- package/dist/config-4QZMRSL3.js +14 -0
- package/dist/fs-J6DIV6CX.js +28 -0
- package/dist/index.d.ts +276 -2
- package/dist/index.js +1649 -38
- package/dist/paths-64GA32IZ.js +28 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1343,6 +1343,11 @@ declare function agentKickoffMessage(opts: {
|
|
|
1343
1343
|
changeId: string;
|
|
1344
1344
|
/** What just happened, e.g. "new change", "advanced to implement" */
|
|
1345
1345
|
event?: string;
|
|
1346
|
+
/**
|
|
1347
|
+
* When set, replaces the default "do current stage work" tail
|
|
1348
|
+
* (used by sdd refine and other specialized modes).
|
|
1349
|
+
*/
|
|
1350
|
+
instructions?: string;
|
|
1346
1351
|
}): string;
|
|
1347
1352
|
/** Write .sdd/active-context.md for the current change. */
|
|
1348
1353
|
declare function refreshActiveAgentContext(projectRoot: string): Promise<string | null>;
|
|
@@ -1398,7 +1403,7 @@ declare function uniqueChangeDirName(base: string, taken: Set<string>): string;
|
|
|
1398
1403
|
* Packaged default assets shipped with @structured-vibe-coding/core.
|
|
1399
1404
|
* Resolves correctly for:
|
|
1400
1405
|
* - package layout: packages/core/dist/index.js → ../defaults
|
|
1401
|
-
* -
|
|
1406
|
+
* - source/tests: packages/core/src → ../defaults
|
|
1402
1407
|
*/
|
|
1403
1408
|
declare function defaultsRoot(): string;
|
|
1404
1409
|
declare function defaultWorkflowsDir(): string;
|
|
@@ -1423,4 +1428,273 @@ declare function copyDirSkipExisting(src: string, dest: string): Promise<void>;
|
|
|
1423
1428
|
declare function writeTextIfMissing(path: string, content: string): Promise<boolean>;
|
|
1424
1429
|
declare function removePath(path: string): Promise<void>;
|
|
1425
1430
|
|
|
1426
|
-
|
|
1431
|
+
/**
|
|
1432
|
+
* Public + internal types for the on-demand structure-aware code context pipeline.
|
|
1433
|
+
* Contracts: LLD §2.1 / research §6.5.
|
|
1434
|
+
*/
|
|
1435
|
+
interface CodeContextCaps {
|
|
1436
|
+
/** Max source files to fully parse (after focus expansion). Default: 40 */
|
|
1437
|
+
maxFiles: number;
|
|
1438
|
+
/** Max ranked symbols to consider for slicing. Default: 30 */
|
|
1439
|
+
maxSymbols: number;
|
|
1440
|
+
/** Max code slices in output. Default: 20 */
|
|
1441
|
+
maxSlices: number;
|
|
1442
|
+
/** Max lines per slice body. Default: 80 */
|
|
1443
|
+
maxLinesPerSlice: number;
|
|
1444
|
+
/** Soft budget for entire markdown body (approx). Default: 8000 */
|
|
1445
|
+
maxOutputLines: number;
|
|
1446
|
+
/** Approx token budget (chars/4 heuristic OK for v1). Default: 12000 */
|
|
1447
|
+
maxTokensApprox: number;
|
|
1448
|
+
/** Max hop distance on import graph from seed files. Default: 1 */
|
|
1449
|
+
maxImportHops: number;
|
|
1450
|
+
}
|
|
1451
|
+
declare const DEFAULT_CODE_CONTEXT_CAPS: CodeContextCaps;
|
|
1452
|
+
interface CodeContextRequest {
|
|
1453
|
+
projectRoot: string;
|
|
1454
|
+
/** Active change id when known; null = flags-only / no change pack signals */
|
|
1455
|
+
changeId?: string | null;
|
|
1456
|
+
/** Explicit paths (files or dirs), repo-relative or absolute */
|
|
1457
|
+
paths?: string[];
|
|
1458
|
+
/** Symbol names to prioritize (e.g. function/class/export) */
|
|
1459
|
+
symbols?: string[];
|
|
1460
|
+
/** Free-text focus (task phrase); used for keyword ranking only */
|
|
1461
|
+
query?: string;
|
|
1462
|
+
caps?: Partial<CodeContextCaps>;
|
|
1463
|
+
/** When true, include more structural neighbors within caps. Default false */
|
|
1464
|
+
includeNeighbors?: boolean;
|
|
1465
|
+
/**
|
|
1466
|
+
* If set, also write regenerable markdown to this absolute path.
|
|
1467
|
+
* Core may write the file; CLI decides default path under changes/<id>/.
|
|
1468
|
+
*/
|
|
1469
|
+
writeArtifactTo?: string | null;
|
|
1470
|
+
}
|
|
1471
|
+
type CodeContextGapCode = "no_focus" | "path_missing" | "path_denied_secret" | "path_ignored" | "unsupported_language" | "parse_error" | "empty_extract" | "cap_truncated" | "no_active_change" | "change_not_found" | "adapter_unavailable";
|
|
1472
|
+
interface CodeContextGap {
|
|
1473
|
+
code: CodeContextGapCode;
|
|
1474
|
+
message: string;
|
|
1475
|
+
path?: string;
|
|
1476
|
+
detail?: string;
|
|
1477
|
+
}
|
|
1478
|
+
type SymbolKind = "function" | "class" | "interface" | "type" | "const" | "export" | "unknown";
|
|
1479
|
+
interface SymbolInfo {
|
|
1480
|
+
name: string;
|
|
1481
|
+
kind: SymbolKind;
|
|
1482
|
+
filePath: string;
|
|
1483
|
+
startLine: number;
|
|
1484
|
+
endLine: number;
|
|
1485
|
+
exported: boolean;
|
|
1486
|
+
}
|
|
1487
|
+
interface CodeSlice {
|
|
1488
|
+
id: string;
|
|
1489
|
+
filePath: string;
|
|
1490
|
+
startLine: number;
|
|
1491
|
+
endLine: number;
|
|
1492
|
+
symbolName?: string;
|
|
1493
|
+
reason: string;
|
|
1494
|
+
body: string;
|
|
1495
|
+
}
|
|
1496
|
+
interface CodeContextSummary {
|
|
1497
|
+
focusPaths: string[];
|
|
1498
|
+
focusSymbols: string[];
|
|
1499
|
+
keywords: string[];
|
|
1500
|
+
filesAnalyzed: number;
|
|
1501
|
+
symbolsExtracted: number;
|
|
1502
|
+
slicesEmitted: number;
|
|
1503
|
+
truncated: boolean;
|
|
1504
|
+
}
|
|
1505
|
+
interface CodeContextResult {
|
|
1506
|
+
ok: boolean;
|
|
1507
|
+
markdown: string;
|
|
1508
|
+
summary: CodeContextSummary;
|
|
1509
|
+
slices: CodeSlice[];
|
|
1510
|
+
gaps: CodeContextGap[];
|
|
1511
|
+
artifactPath?: string;
|
|
1512
|
+
}
|
|
1513
|
+
/** Internal focus plan after FocusResolver. */
|
|
1514
|
+
interface FocusPlan {
|
|
1515
|
+
seedPaths: string[];
|
|
1516
|
+
seedSymbols: string[];
|
|
1517
|
+
keywords: string[];
|
|
1518
|
+
candidatePaths: string[];
|
|
1519
|
+
changeId: string | null;
|
|
1520
|
+
notes: string[];
|
|
1521
|
+
}
|
|
1522
|
+
declare function mergeCaps(partial?: Partial<CodeContextCaps>): CodeContextCaps;
|
|
1523
|
+
|
|
1524
|
+
interface LanguageAdapter {
|
|
1525
|
+
readonly id: string;
|
|
1526
|
+
readonly extensions: string[];
|
|
1527
|
+
/**
|
|
1528
|
+
* Extract symbols + imports/exports + local references.
|
|
1529
|
+
* Must not throw for recoverable parse issues — return ok:false + errors.
|
|
1530
|
+
*/
|
|
1531
|
+
extract(input: {
|
|
1532
|
+
filePath: string;
|
|
1533
|
+
source: string;
|
|
1534
|
+
projectRoot: string;
|
|
1535
|
+
}): Promise<AdapterExtractResult> | AdapterExtractResult;
|
|
1536
|
+
}
|
|
1537
|
+
interface AdapterExtractResult {
|
|
1538
|
+
ok: boolean;
|
|
1539
|
+
language: string;
|
|
1540
|
+
symbols: SymbolInfo[];
|
|
1541
|
+
imports: {
|
|
1542
|
+
from: string;
|
|
1543
|
+
names?: string[];
|
|
1544
|
+
}[];
|
|
1545
|
+
exports: {
|
|
1546
|
+
name: string;
|
|
1547
|
+
kind?: string;
|
|
1548
|
+
}[];
|
|
1549
|
+
/** Optional: name references found in this file (for GraphLite) */
|
|
1550
|
+
references?: {
|
|
1551
|
+
name: string;
|
|
1552
|
+
line: number;
|
|
1553
|
+
}[];
|
|
1554
|
+
errors?: string[];
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Formatter: stable agent-facing markdown (LLD §2.6).
|
|
1559
|
+
*/
|
|
1560
|
+
|
|
1561
|
+
declare function formatJsonSummary(summary: CodeContextSummary, gaps: CodeContextGap[], slices: CodeSlice[], ok: boolean): string;
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* FocusResolver: resolve seed paths, symbols, keywords from request + change pack.
|
|
1565
|
+
* LLD §2.3 / research §5.2–5.3.
|
|
1566
|
+
*/
|
|
1567
|
+
|
|
1568
|
+
declare function tokenizeKeywords(text: string): string[];
|
|
1569
|
+
interface ResolveFocusResult {
|
|
1570
|
+
plan: FocusPlan;
|
|
1571
|
+
gaps: CodeContextGap[];
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Resolve FocusPlan from request. Does not hard-fail; caller treats empty seeds as no_focus.
|
|
1575
|
+
*/
|
|
1576
|
+
declare function resolveFocus(request: CodeContextRequest, options?: {
|
|
1577
|
+
maxCandidateWalk?: number;
|
|
1578
|
+
}): Promise<ResolveFocusResult>;
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Hard-deny secret/credential paths before parse (LLD §2.10 / ARB #3, #6).
|
|
1582
|
+
* Never put denied path contents into slices or gap detail.
|
|
1583
|
+
*/
|
|
1584
|
+
/**
|
|
1585
|
+
* Returns true if the path should never be analyzed (secret/credentials risk).
|
|
1586
|
+
* Matches on normalized path segments and basename.
|
|
1587
|
+
*/
|
|
1588
|
+
declare function isSecretPath(filePath: string): boolean;
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Practical ignore filters for noise paths (soft-skip, gap path_ignored).
|
|
1592
|
+
*/
|
|
1593
|
+
/**
|
|
1594
|
+
* Soft-skip noise: node_modules, dist, coverage, binaries.
|
|
1595
|
+
* Does not include secret paths (those are hard-deny via secrets.ts).
|
|
1596
|
+
*/
|
|
1597
|
+
declare function isIgnoredPath(filePath: string): boolean;
|
|
1598
|
+
type PathFilterKind = "allowed" | "secret" | "ignored";
|
|
1599
|
+
declare function classifyPath(filePath: string): PathFilterKind;
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* Extension → adapter registry. Default maps TS/JS only.
|
|
1603
|
+
* Unknown extensions: no adapter (orchestrator soft-skips).
|
|
1604
|
+
*/
|
|
1605
|
+
declare class AdapterRegistry {
|
|
1606
|
+
private byExt;
|
|
1607
|
+
constructor(adapters?: LanguageAdapter[]);
|
|
1608
|
+
getByPath(filePath: string): LanguageAdapter | undefined;
|
|
1609
|
+
hasExtension(ext: string): boolean;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* TypeScript/JavaScript LanguageAdapter using the TypeScript Compiler API.
|
|
1614
|
+
*
|
|
1615
|
+
* Packaging (research §4.2 / ARB #5):
|
|
1616
|
+
* - `typescript` is a **runtime dependency** of @structured-vibe-coding/core.
|
|
1617
|
+
* - Dual TypeScript copies in consumer monorepos are intentional isolation:
|
|
1618
|
+
* this adapter uses core's own `typescript` for syntactic `createSourceFile`
|
|
1619
|
+
* only. It never loads the host project's TypeScript instance or merges a
|
|
1620
|
+
* full Program / typechecker.
|
|
1621
|
+
*/
|
|
1622
|
+
|
|
1623
|
+
declare const typescriptAdapter: LanguageAdapter;
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* Shallow text fallback for unknown languages.
|
|
1627
|
+
* Exists for tests / future opt-in only — NOT used by default for unknown langs
|
|
1628
|
+
* (research §4.4: skip + unsupported_language gap).
|
|
1629
|
+
*/
|
|
1630
|
+
declare const fallbackAdapter: LanguageAdapter;
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* On-demand structure-aware code context pipeline (Option A).
|
|
1634
|
+
* Public entry: generateCodeContext
|
|
1635
|
+
*/
|
|
1636
|
+
|
|
1637
|
+
/** Optional deps for tests (inject adapters). */
|
|
1638
|
+
type GenerateCodeContextDeps = {
|
|
1639
|
+
adapters?: LanguageAdapter[];
|
|
1640
|
+
now?: () => Date;
|
|
1641
|
+
};
|
|
1642
|
+
/**
|
|
1643
|
+
* Main entry: on-demand pipeline. Partial success returns ok:true with gaps.
|
|
1644
|
+
* Hard failures return ok:false with gaps and minimal markdown explaining failure.
|
|
1645
|
+
*/
|
|
1646
|
+
declare function generateCodeContext(request: CodeContextRequest, deps?: GenerateCodeContextDeps): Promise<CodeContextResult>;
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Stage-scoped refine: plan + brief for the coding agent.
|
|
1650
|
+
* Constitution is read-only; prior pack artifacts are impact-scanned;
|
|
1651
|
+
* process is never blocked.
|
|
1652
|
+
*/
|
|
1653
|
+
|
|
1654
|
+
type RefineMode = "refine" | "analyze";
|
|
1655
|
+
interface BuildRefinePlanOptions {
|
|
1656
|
+
projectRoot: string;
|
|
1657
|
+
config: Config;
|
|
1658
|
+
changeId: string;
|
|
1659
|
+
/** Stage to refine (default: current meta.stage) */
|
|
1660
|
+
stageId?: string;
|
|
1661
|
+
/** Only edit focus-stage files; still read prior + constitution */
|
|
1662
|
+
focusOnly?: boolean;
|
|
1663
|
+
mode?: RefineMode;
|
|
1664
|
+
}
|
|
1665
|
+
interface RefineArtifactRef {
|
|
1666
|
+
stageId: string;
|
|
1667
|
+
path: string;
|
|
1668
|
+
required: boolean;
|
|
1669
|
+
absPath: string;
|
|
1670
|
+
}
|
|
1671
|
+
interface RefinePlan {
|
|
1672
|
+
changeId: string;
|
|
1673
|
+
title: string;
|
|
1674
|
+
workflow: string;
|
|
1675
|
+
focusStageId: string;
|
|
1676
|
+
focusStageTitle: string;
|
|
1677
|
+
mode: RefineMode;
|
|
1678
|
+
focusOnly: boolean;
|
|
1679
|
+
focusArtifacts: RefineArtifactRef[];
|
|
1680
|
+
priorArtifacts: RefineArtifactRef[];
|
|
1681
|
+
laterArtifacts: RefineArtifactRef[];
|
|
1682
|
+
constitutionPath: string;
|
|
1683
|
+
constitutionExists: boolean;
|
|
1684
|
+
changePath: string;
|
|
1685
|
+
briefPath: string;
|
|
1686
|
+
reportPath: string;
|
|
1687
|
+
openItemsPath: string;
|
|
1688
|
+
/** Short CLI kickoff line */
|
|
1689
|
+
kickoff: string;
|
|
1690
|
+
/** Full brief markdown written to briefPath */
|
|
1691
|
+
briefMarkdown: string;
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Build a refine plan for the active (or given) change and optional stage.
|
|
1695
|
+
*/
|
|
1696
|
+
declare function buildRefinePlan(opts: BuildRefinePlanOptions): Promise<RefinePlan>;
|
|
1697
|
+
/** Write refine brief under the change pack (and a pointer under .sdd/). */
|
|
1698
|
+
declare function writeRefineBrief(plan: RefinePlan, projectRoot: string): Promise<string>;
|
|
1699
|
+
|
|
1700
|
+
export { AGENT_INTEGRATIONS, AGENT_TARGET_OPTIONS, ALL_AGENT_TARGETS, type AdapterExtractResult, AdapterRegistry, type AdvanceResult, type AgentIntegration, type AgentTarget, type AgentTargetOption, type ArtifactDef, ArtifactDefSchema, type BuildRefinePlanOptions, type ChangeContext, type ChangeMeta, ChangeMetaSchema, type CodeContextCaps, type CodeContextGap, type CodeContextGapCode, type CodeContextRequest, type CodeContextResult, type CodeContextSummary, type CodeSlice, type Complexity, type Config, ConfigSchema, type CreateChangeInput, DEFAULT_CODE_CONTEXT_CAPS, DEFAULT_INIT_INTEGRATION, type FocusPlan, type Gate, GateSchema, type GenerateCodeContextDeps, type InitOptions, type InitResult, type InstallAgentOptions, type InstallAgentResult, type InstallAgentsOptions, type InstallAgentsResult, type InstalledAgentSnapshot, type LanguageAdapter, PROTOCOL_MD, type RefineArtifactRef, type RefineMode, type RefinePlan, SDD_AGENT_ROLES, SDD_DIR, type SddAgentRole, type SddAgentRoleId, type Stage, StageSchema, type SymbolInfo, type SymbolKind, VerifyCommandSchema, type VerifyResult, type Workflow, WorkflowSchema, activePointerPath, activeStages, advanceStage, agentHostPaths, agentKickoffMessage, approveGate, archiveDir, buildAgentPrompt, buildContext, buildRefinePlan, canLeaveStage, changeDirName, changeMetaPath, changePath, changesDir, classifyPath, clearActiveIf, completeChange, configPath, copyDir, copyDirSkipExisting, createChange, defaultConfig, defaultMemoryDir, defaultTemplatesDir, defaultWorkflowsDir, defaultsRoot, domainsDir, ensureDir, fallbackAdapter, fallbackIncompleteStageId, firstActiveStageId, formatJsonSummary, formatStatus, generateCodeContext, getActiveChangeId, getIntegration, getStage, incompletePriorStageErrors, inferComplexity, initProject, installAgentIntegration, installAgentIntegrations, integrationKeyFor, isIgnoredPath, isInitialized, isSecretPath, isStageSkipped, isSubstantiveArtifactContent, listChanges, listDirs, listFiles, listWorkflowNames, loadChangeMeta, loadConfig, loadInstalledAgent, loadWorkflow, memoryDir, mergeCaps, nextStageId, nowIso, optionForTarget, parseAgentTargets, parseIntegration, pathExists, readText, readYaml, recommendWorkflow, refreshActiveAgentContext, removeOtherAgentHosts, removePath, renderThinAgent, resolveChangeId, resolveFocus, resolveStages, runLocalVerify, saveChangeMeta, saveConfig, sddRoot, setActiveChange, shouldAutoSkip, skipStage, slugify, switchWorkflow, templatesDir, todayIsoDate, tokenizeKeywords, typescriptAdapter, uniqueChangeDirName, workflowsDir, writeAgentHandoff, writeRefineBrief, writeText, writeTextIfMissing, writeYaml };
|