@isaacriehm/cairn-core 0.1.10 → 0.2.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/dist/.tsbuildinfo +1 -1
- package/dist/context/checkpoint.d.ts +4 -3
- package/dist/context/checkpoint.js +4 -3
- package/dist/context/checkpoint.js.map +1 -1
- package/dist/context/index.d.ts +2 -2
- package/dist/context/index.js +2 -2
- package/dist/context/spec-delta.js +1 -1
- package/dist/context/spec-delta.js.map +1 -1
- package/dist/doctor/index.d.ts +1 -1
- package/dist/doctor/index.js +4 -59
- package/dist/doctor/index.js.map +1 -1
- package/dist/frontend-types.d.ts +3 -3
- package/dist/frontend-types.js +3 -3
- package/dist/gc/quality-update.d.ts +4 -4
- package/dist/gc/quality-update.js +4 -4
- package/dist/ground/manifest.js +0 -2
- package/dist/ground/manifest.js.map +1 -1
- package/dist/ground/paths.js +0 -1
- package/dist/ground/paths.js.map +1 -1
- package/dist/ground/scope-index.d.ts +3 -2
- package/dist/ground/scope-index.js +3 -2
- package/dist/ground/scope-index.js.map +1 -1
- package/dist/hooks/bypass-detection.js +13 -18
- package/dist/hooks/bypass-detection.js.map +1 -1
- package/dist/hooks/defer.d.ts +50 -0
- package/dist/hooks/defer.js +87 -0
- package/dist/hooks/defer.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/post-tool-use/ledger-cache.d.ts +2 -2
- package/dist/hooks/post-tool-use/ledger-cache.js +5 -4
- package/dist/hooks/post-tool-use/ledger-cache.js.map +1 -1
- package/dist/hooks/runners/index.d.ts +2 -0
- package/dist/hooks/runners/index.js +1 -0
- package/dist/hooks/runners/index.js.map +1 -1
- package/dist/hooks/runners/session-start.js +47 -18
- package/dist/hooks/runners/session-start.js.map +1 -1
- package/dist/hooks/runners/stop.js +81 -24
- package/dist/hooks/runners/stop.js.map +1 -1
- package/dist/hooks/seed-attested.d.ts +25 -0
- package/dist/hooks/seed-attested.js +84 -0
- package/dist/hooks/seed-attested.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +2 -0
- package/dist/init/index.js +1 -0
- package/dist/init/index.js.map +1 -1
- package/dist/init/init.js +8 -90
- package/dist/init/init.js.map +1 -1
- package/dist/init/mapper.d.ts +1 -1
- package/dist/init/multi-dev/install.d.ts +15 -10
- package/dist/init/multi-dev/install.js +17 -84
- package/dist/init/multi-dev/install.js.map +1 -1
- package/dist/init/overlay.d.ts +14 -0
- package/dist/init/overlay.js +65 -0
- package/dist/init/overlay.js.map +1 -0
- package/dist/init/phases/1-detect.d.ts +10 -0
- package/dist/init/phases/1-detect.js +36 -0
- package/dist/init/phases/1-detect.js.map +1 -0
- package/dist/init/phases/10-strip.d.ts +11 -0
- package/dist/init/phases/10-strip.js +80 -0
- package/dist/init/phases/10-strip.js.map +1 -0
- package/dist/init/phases/12-multidev.d.ts +11 -0
- package/dist/init/phases/12-multidev.js +39 -0
- package/dist/init/phases/12-multidev.js.map +1 -0
- package/dist/init/phases/2-walker.d.ts +8 -0
- package/dist/init/phases/2-walker.js +34 -0
- package/dist/init/phases/2-walker.js.map +1 -0
- package/dist/init/phases/3-mapper.d.ts +14 -0
- package/dist/init/phases/3-mapper.js +56 -0
- package/dist/init/phases/3-mapper.js.map +1 -0
- package/dist/init/phases/3b-seed.d.ts +27 -0
- package/dist/init/phases/3b-seed.js +149 -0
- package/dist/init/phases/3b-seed.js.map +1 -0
- package/dist/init/phases/4-pilot.d.ts +10 -0
- package/dist/init/phases/4-pilot.js +70 -0
- package/dist/init/phases/4-pilot.js.map +1 -0
- package/dist/init/phases/5-brand.d.ts +10 -0
- package/dist/init/phases/5-brand.js +66 -0
- package/dist/init/phases/5-brand.js.map +1 -0
- package/dist/init/phases/6-docs-ingest.d.ts +11 -0
- package/dist/init/phases/6-docs-ingest.js +39 -0
- package/dist/init/phases/6-docs-ingest.js.map +1 -0
- package/dist/init/phases/7b-source-comments.d.ts +6 -0
- package/dist/init/phases/7b-source-comments.js +34 -0
- package/dist/init/phases/7b-source-comments.js.map +1 -0
- package/dist/init/phases/7c-rules-merge.d.ts +6 -0
- package/dist/init/phases/7c-rules-merge.js +34 -0
- package/dist/init/phases/7c-rules-merge.js.map +1 -0
- package/dist/init/phases/8-baseline.d.ts +10 -0
- package/dist/init/phases/8-baseline.js +52 -0
- package/dist/init/phases/8-baseline.js.map +1 -0
- package/dist/init/phases/index.d.ts +15 -0
- package/dist/init/phases/index.js +16 -0
- package/dist/init/phases/index.js.map +1 -0
- package/dist/init/phases/orchestrator.d.ts +49 -0
- package/dist/init/phases/orchestrator.js +85 -0
- package/dist/init/phases/orchestrator.js.map +1 -0
- package/dist/init/phases/state-io.d.ts +19 -0
- package/dist/init/phases/state-io.js +73 -0
- package/dist/init/phases/state-io.js.map +1 -0
- package/dist/init/phases/types.d.ts +93 -0
- package/dist/init/phases/types.js +30 -0
- package/dist/init/phases/types.js.map +1 -0
- package/dist/init/seed.js +11 -2
- package/dist/init/seed.js.map +1 -1
- package/dist/init/walker.d.ts +0 -6
- package/dist/init/walker.js +2 -3
- package/dist/init/walker.js.map +1 -1
- package/dist/join/index.js +49 -2
- package/dist/join/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +5 -5
- package/dist/logger.js.map +1 -1
- package/dist/mcp/errors.d.ts +1 -1
- package/dist/mcp/schemas.d.ts +19 -0
- package/dist/mcp/schemas.js +19 -0
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/tools/append-run-note.js +13 -6
- package/dist/mcp/tools/append-run-note.js.map +1 -1
- package/dist/mcp/tools/drop-task.js +1 -1
- package/dist/mcp/tools/drop-task.js.map +1 -1
- package/dist/mcp/tools/ground-get.js +2 -2
- package/dist/mcp/tools/ground-get.js.map +1 -1
- package/dist/mcp/tools/index.js +4 -0
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/init-phases.d.ts +24 -0
- package/dist/mcp/tools/init-phases.js +140 -0
- package/dist/mcp/tools/init-phases.js.map +1 -0
- package/dist/mcp/tools/query-history.js +1 -1
- package/dist/mcp/tools/query-history.js.map +1 -1
- package/dist/mcp/tools/resolve-attention.d.ts +3 -1
- package/dist/mcp/tools/resolve-attention.js +228 -11
- package/dist/mcp/tools/resolve-attention.js.map +1 -1
- package/dist/profiles/types.d.ts +1 -1
- package/dist/sensors/catalog.js +8 -3
- package/dist/sensors/catalog.js.map +1 -1
- package/dist/session-start/build.d.ts +4 -0
- package/dist/session-start/build.js +7 -0
- package/dist/session-start/build.js.map +1 -1
- package/dist/status-line/format.d.ts +10 -7
- package/dist/status-line/format.js +16 -14
- package/dist/status-line/format.js.map +1 -1
- package/dist/status-line/index.d.ts +0 -3
- package/dist/status-line/index.js.map +1 -1
- package/dist/status-line/reader.d.ts +1 -1
- package/dist/status-line/reader.js +2 -5
- package/dist/status-line/reader.js.map +1 -1
- package/dist/status-line/writer.d.ts +1 -9
- package/dist/status-line/writer.js +1 -12
- package/dist/status-line/writer.js.map +1 -1
- package/package.json +1 -1
- package/templates/.cairn/JOIN.md +3 -9
- package/templates/.cairn/git-hooks/commit-msg +14 -3
- package/templates/.cairn/git-hooks/pre-commit +22 -13
- package/templates/README.md +0 -24
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 3b-seed — write `.cairn/` skeleton + project overlay +
|
|
3
|
+
* grandfather pre-adoption commits.
|
|
4
|
+
*
|
|
5
|
+
* Bridges 3-mapper and 4-pilot. Without this phase the v0.2.0 init
|
|
6
|
+
* pipeline produced an `.cairn/` populated only by side effects of
|
|
7
|
+
* downstream phases (events/, baseline/, ground/decisions/_inbox/)
|
|
8
|
+
* but never wrote `config.yaml`, `git-hooks/`, or the brand /
|
|
9
|
+
* canonical-map / capabilities skeleton — leaving the project in a
|
|
10
|
+
* "half-adopted" shape that subsequent SessionStarts could not
|
|
11
|
+
* detect as adopted.
|
|
12
|
+
*
|
|
13
|
+
* Steps:
|
|
14
|
+
* 1. seedCairnLayout (templates → .cairn/)
|
|
15
|
+
* 2. updateWorkflowSlugBlock (mapper output → workflow.md)
|
|
16
|
+
* 3. write .cairn/config.yaml + .cairn/ground/scope-index.yaml
|
|
17
|
+
* 4. seed .cairn/.attested-commits with every reachable HEAD SHA
|
|
18
|
+
* so the Stop-hook bypass detector grandfathers pre-adoption
|
|
19
|
+
* history (otherwise the very next assistant turn flags every
|
|
20
|
+
* pre-adoption commit as a `--no-verify` bypass).
|
|
21
|
+
*
|
|
22
|
+
* No operator input. Always advances. Idempotent — re-running on a
|
|
23
|
+
* project that already has .cairn/ keeps existing files (collisions
|
|
24
|
+
* recorded in seed.collisions but not fatal).
|
|
25
|
+
*/
|
|
26
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
import { stringify as stringifyYaml } from "yaml";
|
|
29
|
+
import { scopeIndexPath, writeScopeIndex, } from "../../ground/scope-index.js";
|
|
30
|
+
import { seedAttestedCommits } from "../../hooks/seed-attested.js";
|
|
31
|
+
import { buildProjectOverlay } from "../overlay.js";
|
|
32
|
+
import { seedCairnLayout } from "../seed.js";
|
|
33
|
+
import { updateWorkflowSlugBlock } from "../workflow-block.js";
|
|
34
|
+
import { advancePhase } from "./orchestrator.js";
|
|
35
|
+
export async function runPhase3bSeed(state) {
|
|
36
|
+
const detection = state.outputs["1-detect"];
|
|
37
|
+
const mapperResult = state.outputs["3-mapper"];
|
|
38
|
+
if (detection === undefined) {
|
|
39
|
+
return {
|
|
40
|
+
status: "error",
|
|
41
|
+
error: {
|
|
42
|
+
code: "missing-prereqs",
|
|
43
|
+
message: "Phase 3b-seed needs phase 1-detect output",
|
|
44
|
+
},
|
|
45
|
+
state,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const projectSlug = detection.project_slug;
|
|
49
|
+
const mapperOutput = mapperResult?.output;
|
|
50
|
+
try {
|
|
51
|
+
// Step 1 — seed templates into .cairn/.
|
|
52
|
+
const seed = seedCairnLayout({ repoRoot: state.repoRoot, projectSlug });
|
|
53
|
+
// Step 2 — patch <slug>: workflow.md block when workflow.md was
|
|
54
|
+
// freshly seeded (existing workflow stays untouched on re-run).
|
|
55
|
+
const wfRel = ".cairn/config/workflow.md";
|
|
56
|
+
const wfWasSeeded = seed.written_files.includes(wfRel);
|
|
57
|
+
let workflowSlugPatched = false;
|
|
58
|
+
let workflowPatchError = null;
|
|
59
|
+
if (mapperOutput !== undefined && wfWasSeeded) {
|
|
60
|
+
try {
|
|
61
|
+
updateWorkflowSlugBlock({
|
|
62
|
+
workflowMdPath: join(state.repoRoot, wfRel),
|
|
63
|
+
slug: projectSlug,
|
|
64
|
+
update: {
|
|
65
|
+
pilot_module: mapperOutput.pilot_module,
|
|
66
|
+
route_handler_globs: mapperOutput.route_handler_globs,
|
|
67
|
+
dto_globs: mapperOutput.dto_globs,
|
|
68
|
+
generator_source_globs: mapperOutput.generator_source_globs,
|
|
69
|
+
high_stakes_globs: mapperOutput.high_stakes_globs,
|
|
70
|
+
off_limits_append: mapperOutput.off_limits_globs,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
workflowSlugPatched = true;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
// Soft fail — record the error and continue. config.yaml +
|
|
77
|
+
// scope-index still get written below; the operator can
|
|
78
|
+
// hand-edit workflow.md after init if needed.
|
|
79
|
+
workflowPatchError =
|
|
80
|
+
err instanceof Error ? err.stack ?? err.message : String(err);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Step 3 — write .cairn/config.yaml.
|
|
84
|
+
const configPath = join(state.repoRoot, ".cairn", "config.yaml");
|
|
85
|
+
mkdirSync(join(state.repoRoot, ".cairn"), { recursive: true });
|
|
86
|
+
if (!existsSync(configPath)) {
|
|
87
|
+
const config = buildProjectOverlay({
|
|
88
|
+
detection,
|
|
89
|
+
decidedSlug: projectSlug,
|
|
90
|
+
...(mapperOutput !== undefined ? { mapperOutput } : {}),
|
|
91
|
+
});
|
|
92
|
+
writeFileSync(configPath, stringifyYaml(config), "utf8");
|
|
93
|
+
}
|
|
94
|
+
// Step 4 — write .cairn/ground/scope-index.yaml from mapper.
|
|
95
|
+
const scopeFile = scopeIndexPath(state.repoRoot);
|
|
96
|
+
if (!existsSync(scopeFile)) {
|
|
97
|
+
const seedFiles = {};
|
|
98
|
+
const mapperFiles = mapperOutput?.scope_index?.files ?? {};
|
|
99
|
+
for (const [path, e] of Object.entries(mapperFiles)) {
|
|
100
|
+
const entry = {
|
|
101
|
+
decisions: e.decisions,
|
|
102
|
+
invariants: e.invariants,
|
|
103
|
+
};
|
|
104
|
+
if (e.unscoped === true)
|
|
105
|
+
entry.unscoped = true;
|
|
106
|
+
seedFiles[path] = entry;
|
|
107
|
+
}
|
|
108
|
+
writeScopeIndex(state.repoRoot, {
|
|
109
|
+
generated: new Date().toISOString(),
|
|
110
|
+
files: seedFiles,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
// Step 5 — grandfather pre-adoption commits in
|
|
114
|
+
// `.cairn/.attested-commits` so the Stop-hook bypass detector
|
|
115
|
+
// doesn't flag every pre-existing SHA on the next turn.
|
|
116
|
+
const attestedSeed = seedAttestedCommits(state.repoRoot);
|
|
117
|
+
const out = {
|
|
118
|
+
written_files: seed.written_files,
|
|
119
|
+
collisions: seed.collisions,
|
|
120
|
+
config_path: ".cairn/config.yaml",
|
|
121
|
+
scope_index_path: ".cairn/ground/scope-index.yaml",
|
|
122
|
+
workflow_slug_patched: workflowSlugPatched,
|
|
123
|
+
workflow_patch_error: workflowPatchError,
|
|
124
|
+
attested_seeded: attestedSeed.count ?? 0,
|
|
125
|
+
attested_seed_status: attestedSeed.status,
|
|
126
|
+
};
|
|
127
|
+
const next = {
|
|
128
|
+
...state,
|
|
129
|
+
outputs: { ...state.outputs, "3b-seed": out },
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
status: "complete",
|
|
133
|
+
nextPhase: "4-pilot",
|
|
134
|
+
state: advancePhase(next),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
return {
|
|
139
|
+
status: "error",
|
|
140
|
+
error: {
|
|
141
|
+
code: "seed-failed",
|
|
142
|
+
message: "Failed to seed .cairn/ skeleton",
|
|
143
|
+
detail: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
144
|
+
},
|
|
145
|
+
state,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=3b-seed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3b-seed.js","sourceRoot":"","sources":["../../../src/init/phases/3b-seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EACL,cAAc,EACd,eAAe,GAGhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcjD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAiB;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAgC,CAAC;IAC3E,MAAM,YAAY,GAAG,KAAK,CAAC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,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 4-pilot — operator picks the seed module.
|
|
3
|
+
*
|
|
4
|
+
* The mapper's `pilot_module` field is the model's first guess; this
|
|
5
|
+
* phase surfaces it alongside the next 2 strongest `key_modules` so
|
|
6
|
+
* the operator can override. Picking the pilot determines which
|
|
7
|
+
* module's globs flow into `.cairn/config.yaml.project_globs` first.
|
|
8
|
+
*/
|
|
9
|
+
import type { PhaseResult, PhaseState } from "./types.js";
|
|
10
|
+
export declare function runPhase4Pilot(state: PhaseState): Promise<PhaseResult>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 4-pilot — operator picks the seed module.
|
|
3
|
+
*
|
|
4
|
+
* The mapper's `pilot_module` field is the model's first guess; this
|
|
5
|
+
* phase surfaces it alongside the next 2 strongest `key_modules` so
|
|
6
|
+
* the operator can override. Picking the pilot determines which
|
|
7
|
+
* module's globs flow into `.cairn/config.yaml.project_globs` first.
|
|
8
|
+
*/
|
|
9
|
+
import { advancePhase } from "./orchestrator.js";
|
|
10
|
+
const MAX_OPTIONS = 3;
|
|
11
|
+
export async function runPhase4Pilot(state) {
|
|
12
|
+
const mapper = state.outputs["3-mapper"];
|
|
13
|
+
if (mapper === undefined) {
|
|
14
|
+
return {
|
|
15
|
+
status: "error",
|
|
16
|
+
error: {
|
|
17
|
+
code: "missing-prereqs",
|
|
18
|
+
message: "Phase 4 needs phase 3-mapper output",
|
|
19
|
+
},
|
|
20
|
+
state,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Operator already picked → consume + advance.
|
|
24
|
+
if (state.answer !== undefined && state.answer.length > 0) {
|
|
25
|
+
const next = {
|
|
26
|
+
...state,
|
|
27
|
+
outputs: { ...state.outputs, "4-pilot": { picked: state.answer } },
|
|
28
|
+
answer: undefined,
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
status: "complete",
|
|
32
|
+
nextPhase: "5-brand",
|
|
33
|
+
state: advancePhase(next),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const out = mapper.output;
|
|
37
|
+
const candidates = [];
|
|
38
|
+
// Pilot first.
|
|
39
|
+
if (out.pilot_module.length > 0) {
|
|
40
|
+
candidates.push({
|
|
41
|
+
id: out.pilot_module,
|
|
42
|
+
label: out.pilot_module,
|
|
43
|
+
detail: "Mapper's first pick",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Top 2 key_modules other than pilot.
|
|
47
|
+
for (const km of out.key_modules) {
|
|
48
|
+
if (candidates.length >= MAX_OPTIONS)
|
|
49
|
+
break;
|
|
50
|
+
if (km.path === out.pilot_module)
|
|
51
|
+
continue;
|
|
52
|
+
candidates.push({
|
|
53
|
+
id: km.path,
|
|
54
|
+
label: km.path,
|
|
55
|
+
detail: km.purpose,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Fallback if mapper produced nothing.
|
|
59
|
+
if (candidates.length === 0) {
|
|
60
|
+
candidates.push({ id: "ALL", label: "ALL", detail: "Whole repo as the pilot scope" });
|
|
61
|
+
}
|
|
62
|
+
const question = {
|
|
63
|
+
id: "4-pilot",
|
|
64
|
+
prompt: "Which module should Cairn seed first?",
|
|
65
|
+
options: candidates,
|
|
66
|
+
default: candidates[0].id,
|
|
67
|
+
};
|
|
68
|
+
return { status: "needs_input", question, state };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=4-pilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"4-pilot.js","sourceRoot":"","sources":["../../../src/init/phases/4-pilot.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,MAAM,WAAW,GAAG,CAAC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,GAAG,CAAC,YAAY;YAAE,SAAS;QAC3C,UAAU,CAAC,IAAI,CAAC;YACd,EAAE,EAAE,EAAE,CAAC,IAAI;YACX,KAAK,EAAE,EAAE,CAAC,IAAI;YACd,MAAM,EAAE,EAAE,CAAC,OAAO;SACnB,CAAC,CAAC;IACL,CAAC;IACD,uCAAuC;IACvC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,+BAA+B,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,QAAQ,GAAkB;QAC9B,EAAE,EAAE,SAAS;QACb,MAAM,EAAE,uCAAuC;QAC/C,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAE,CAAC,EAAE;KAC3B,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5-brand — adopt brand DEC drafts inline.
|
|
3
|
+
*
|
|
4
|
+
* Emits ONE A/B/C choice. `auto-fill` substitutes positioning + voice
|
|
5
|
+
* from the mapper's domain summary; `skip` leaves status: draft for
|
|
6
|
+
* later editing; `manual` hands off to the operator (drafts stay
|
|
7
|
+
* draft, summary surfaces the file paths to edit).
|
|
8
|
+
*/
|
|
9
|
+
import type { PhaseResult, PhaseState } from "./types.js";
|
|
10
|
+
export declare function runPhase5Brand(state: PhaseState): Promise<PhaseResult>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5-brand — adopt brand DEC drafts inline.
|
|
3
|
+
*
|
|
4
|
+
* Emits ONE A/B/C choice. `auto-fill` substitutes positioning + voice
|
|
5
|
+
* from the mapper's domain summary; `skip` leaves status: draft for
|
|
6
|
+
* later editing; `manual` hands off to the operator (drafts stay
|
|
7
|
+
* draft, summary surfaces the file paths to edit).
|
|
8
|
+
*/
|
|
9
|
+
import { applyBrandAnswers } from "../brand-setup.js";
|
|
10
|
+
import { advancePhase } from "./orchestrator.js";
|
|
11
|
+
export async function runPhase5Brand(state) {
|
|
12
|
+
// Pending operator answer → execute the chosen path.
|
|
13
|
+
if (state.answer !== undefined && state.answer.length > 0) {
|
|
14
|
+
const choice = state.answer;
|
|
15
|
+
let result = null;
|
|
16
|
+
if (choice === "auto-fill") {
|
|
17
|
+
const mapper = state.outputs["3-mapper"];
|
|
18
|
+
if (mapper !== undefined) {
|
|
19
|
+
const answers = {
|
|
20
|
+
whatItDoes: mapper.output.domain_summary,
|
|
21
|
+
mainUsers: "",
|
|
22
|
+
voice: "",
|
|
23
|
+
avoid: "",
|
|
24
|
+
};
|
|
25
|
+
result = applyBrandAnswers(state.repoRoot, answers);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const next = {
|
|
29
|
+
...state,
|
|
30
|
+
outputs: {
|
|
31
|
+
...state.outputs,
|
|
32
|
+
"5-brand": { choice, applied: result },
|
|
33
|
+
},
|
|
34
|
+
answer: undefined,
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
status: "complete",
|
|
38
|
+
nextPhase: "6-docs-ingest",
|
|
39
|
+
state: advancePhase(next),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const question = {
|
|
43
|
+
id: "5-brand",
|
|
44
|
+
prompt: "Brand DEC drafts — how should Cairn populate them?",
|
|
45
|
+
options: [
|
|
46
|
+
{
|
|
47
|
+
id: "skip",
|
|
48
|
+
label: "skip — keep drafts blank",
|
|
49
|
+
detail: ".cairn/ground/brand/* stays status: draft",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "auto-fill",
|
|
53
|
+
label: "auto-fill from mapper summary",
|
|
54
|
+
detail: "positioning.md gets the mapper's summary, status flips to current",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "manual",
|
|
58
|
+
label: "manual — edit drafts first",
|
|
59
|
+
detail: "Drafts stay status: draft; you can populate them later",
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
default: "skip",
|
|
63
|
+
};
|
|
64
|
+
return { status: "needs_input", question, state };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=5-brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-brand.js","sourceRoot":"","sources":["../../../src/init/phases/5-brand.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,iBAAiB,EAAqB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAiB;IACpD,qDAAqD;IACrD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,MAAM,GAAqD,IAAI,CAAC;QACpE,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAA6B,CAAC;YACrE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,OAAO,GAAiB;oBAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc;oBACxC,SAAS,EAAE,EAAE;oBACb,KAAK,EAAE,EAAE;oBACT,KAAK,EAAE,EAAE;iBACV,CAAC;gBACF,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE;gBACP,GAAG,KAAK,CAAC,OAAO;gBAChB,SAAS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;aACvC;YACD,MAAM,EAAE,SAAS;SAClB,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAkB;QAC9B,EAAE,EAAE,SAAS;QACb,MAAM,EAAE,oDAAoD;QAC5D,OAAO,EAAE;YACP;gBACE,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE,0BAA0B;gBACjC,MAAM,EAAE,2CAA2C;aACpD;YACD;gBACE,EAAE,EAAE,WAAW;gBACf,KAAK,EAAE,+BAA+B;gBACtC,MAAM,EAAE,mEAAmE;aAC5E;YACD;gBACE,EAAE,EAAE,QAAQ;gBACZ,KAAK,EAAE,4BAA4B;gBACnC,MAAM,EAAE,wDAAwD;aACjE;SACF;QACD,OAAO,EAAE,MAAM;KAChB,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 6-docs-ingest — Haiku batch over README + docs/ → DEC drafts
|
|
3
|
+
* + canonical-map topics + voice rewrites.
|
|
4
|
+
*
|
|
5
|
+
* Wraps `runDocsIngestion`; no operator input. The skill driver
|
|
6
|
+
* surfaces the resulting `decDraftsWritten` count in the post-init
|
|
7
|
+
* summary so the operator knows how much pending attention they
|
|
8
|
+
* have.
|
|
9
|
+
*/
|
|
10
|
+
import type { PhaseResult, PhaseState } from "./types.js";
|
|
11
|
+
export declare function runPhase6DocsIngest(state: PhaseState): Promise<PhaseResult>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 6-docs-ingest — Haiku batch over README + docs/ → DEC drafts
|
|
3
|
+
* + canonical-map topics + voice rewrites.
|
|
4
|
+
*
|
|
5
|
+
* Wraps `runDocsIngestion`; no operator input. The skill driver
|
|
6
|
+
* surfaces the resulting `decDraftsWritten` count in the post-init
|
|
7
|
+
* summary so the operator knows how much pending attention they
|
|
8
|
+
* have.
|
|
9
|
+
*/
|
|
10
|
+
import { runDocsIngestion } from "../ingest-docs.js";
|
|
11
|
+
import { advancePhase } from "./orchestrator.js";
|
|
12
|
+
export async function runPhase6DocsIngest(state) {
|
|
13
|
+
try {
|
|
14
|
+
const result = await runDocsIngestion({
|
|
15
|
+
repoRoot: state.repoRoot,
|
|
16
|
+
});
|
|
17
|
+
const next = {
|
|
18
|
+
...state,
|
|
19
|
+
outputs: { ...state.outputs, "6-docs-ingest": result },
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
status: "complete",
|
|
23
|
+
nextPhase: "7b-source-comments",
|
|
24
|
+
state: advancePhase(next),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return {
|
|
29
|
+
status: "error",
|
|
30
|
+
error: {
|
|
31
|
+
code: "docs-ingest-failed",
|
|
32
|
+
message: "Docs ingestion pipeline failed",
|
|
33
|
+
detail: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
34
|
+
},
|
|
35
|
+
state,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=6-docs-ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"6-docs-ingest.js","sourceRoot":"","sources":["../../../src/init/phases/6-docs-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAAiB;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,GAAoB,MAAM,gBAAgB,CAAC;YACrD,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC,CAAC;QACH,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE;SACvD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,oBAAoB;YAC/B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,gCAAgC;gBACzC,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7b-source-comments — walk every source file's docblock-class
|
|
3
|
+
* comment, classify via Haiku, write DEC drafts / invariant proposals.
|
|
4
|
+
*/
|
|
5
|
+
import type { PhaseResult, PhaseState } from "./types.js";
|
|
6
|
+
export declare function runPhase7bSourceComments(state: PhaseState): Promise<PhaseResult>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7b-source-comments — walk every source file's docblock-class
|
|
3
|
+
* comment, classify via Haiku, write DEC drafts / invariant proposals.
|
|
4
|
+
*/
|
|
5
|
+
import { runSourceCommentsIngestion, } from "../source-comments/index.js";
|
|
6
|
+
import { advancePhase } from "./orchestrator.js";
|
|
7
|
+
export async function runPhase7bSourceComments(state) {
|
|
8
|
+
try {
|
|
9
|
+
const result = await runSourceCommentsIngestion({
|
|
10
|
+
repoRoot: state.repoRoot,
|
|
11
|
+
});
|
|
12
|
+
const next = {
|
|
13
|
+
...state,
|
|
14
|
+
outputs: { ...state.outputs, "7b-source-comments": result },
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
status: "complete",
|
|
18
|
+
nextPhase: "7c-rules-merge",
|
|
19
|
+
state: advancePhase(next),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return {
|
|
24
|
+
status: "error",
|
|
25
|
+
error: {
|
|
26
|
+
code: "source-comments-failed",
|
|
27
|
+
message: "Source-comment ingestion failed",
|
|
28
|
+
detail: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
29
|
+
},
|
|
30
|
+
state,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=7b-source-comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"7b-source-comments.js","sourceRoot":"","sources":["../../../src/init/phases/7b-source-comments.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,KAAiB;IAC9D,IAAI,CAAC;QACH,MAAM,MAAM,GAA+B,MAAM,0BAA0B,CAAC;YAC1E,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC,CAAC;QACH,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE;SAC5D,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,wBAAwB;gBAC9B,OAAO,EAAE,iCAAiC;gBAC1C,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7c-rules-merge — walk CLAUDE.md / AGENTS.md / .claude/rules/*
|
|
3
|
+
* sections, classify via Haiku, propose net-new rules + flag conflicts.
|
|
4
|
+
*/
|
|
5
|
+
import type { PhaseResult, PhaseState } from "./types.js";
|
|
6
|
+
export declare function runPhase7cRulesMerge(state: PhaseState): Promise<PhaseResult>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 7c-rules-merge — walk CLAUDE.md / AGENTS.md / .claude/rules/*
|
|
3
|
+
* sections, classify via Haiku, propose net-new rules + flag conflicts.
|
|
4
|
+
*/
|
|
5
|
+
import { runRulesMerge, } from "../rules-merge/index.js";
|
|
6
|
+
import { advancePhase } from "./orchestrator.js";
|
|
7
|
+
export async function runPhase7cRulesMerge(state) {
|
|
8
|
+
try {
|
|
9
|
+
const result = await runRulesMerge({
|
|
10
|
+
repoRoot: state.repoRoot,
|
|
11
|
+
});
|
|
12
|
+
const next = {
|
|
13
|
+
...state,
|
|
14
|
+
outputs: { ...state.outputs, "7c-rules-merge": result },
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
status: "complete",
|
|
18
|
+
nextPhase: "8-baseline",
|
|
19
|
+
state: advancePhase(next),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return {
|
|
24
|
+
status: "error",
|
|
25
|
+
error: {
|
|
26
|
+
code: "rules-merge-failed",
|
|
27
|
+
message: "Rules merge failed",
|
|
28
|
+
detail: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
29
|
+
},
|
|
30
|
+
state,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=7c-rules-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"7c-rules-merge.js","sourceRoot":"","sources":["../../../src/init/phases/7c-rules-merge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAiB;IAC1D,IAAI,CAAC;QACH,MAAM,MAAM,GAAwB,MAAM,aAAa,CAAC;YACtD,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC,CAAC;QACH,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE;SACxD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,YAAY;YACvB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,oBAAoB;gBAC7B,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 8-baseline — first sensor sweep against the synthetic
|
|
3
|
+
* full-tree diff. Stamps the audit row counts under outputs so the
|
|
4
|
+
* skill driver can summarize "N findings across M sensors".
|
|
5
|
+
*
|
|
6
|
+
* Reads the mapper's globs (route handlers, DTOs, etc.) from phase 3
|
|
7
|
+
* if available. Falls back to baseline-audit's defaults otherwise.
|
|
8
|
+
*/
|
|
9
|
+
import type { PhaseResult, PhaseState } from "./types.js";
|
|
10
|
+
export declare function runPhase8Baseline(state: PhaseState): Promise<PhaseResult>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 8-baseline — first sensor sweep against the synthetic
|
|
3
|
+
* full-tree diff. Stamps the audit row counts under outputs so the
|
|
4
|
+
* skill driver can summarize "N findings across M sensors".
|
|
5
|
+
*
|
|
6
|
+
* Reads the mapper's globs (route handlers, DTOs, etc.) from phase 3
|
|
7
|
+
* if available. Falls back to baseline-audit's defaults otherwise.
|
|
8
|
+
*/
|
|
9
|
+
import { defaultBaselineLanguages, runBaselineAudit, } from "../baseline-audit.js";
|
|
10
|
+
import { advancePhase } from "./orchestrator.js";
|
|
11
|
+
export async function runPhase8Baseline(state) {
|
|
12
|
+
const detection = state.outputs["1-detect"];
|
|
13
|
+
const mapper = state.outputs["3-mapper"];
|
|
14
|
+
const globs = mapper
|
|
15
|
+
? {
|
|
16
|
+
route_handler_globs: mapper.output.route_handler_globs,
|
|
17
|
+
dto_globs: mapper.output.dto_globs,
|
|
18
|
+
generator_source_globs: mapper.output.generator_source_globs,
|
|
19
|
+
high_stakes_globs: mapper.output.high_stakes_globs,
|
|
20
|
+
off_limits: mapper.output.off_limits_globs,
|
|
21
|
+
}
|
|
22
|
+
: {};
|
|
23
|
+
const languages = defaultBaselineLanguages((detection?.stack_signatures ?? []).map((s) => s.kind));
|
|
24
|
+
try {
|
|
25
|
+
const result = await runBaselineAudit({
|
|
26
|
+
repoRoot: state.repoRoot,
|
|
27
|
+
projectGlobs: globs,
|
|
28
|
+
languages,
|
|
29
|
+
});
|
|
30
|
+
const next = {
|
|
31
|
+
...state,
|
|
32
|
+
outputs: { ...state.outputs, "8-baseline": result },
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
status: "complete",
|
|
36
|
+
nextPhase: "10-strip",
|
|
37
|
+
state: advancePhase(next),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
return {
|
|
42
|
+
status: "error",
|
|
43
|
+
error: {
|
|
44
|
+
code: "baseline-failed",
|
|
45
|
+
message: "Baseline sensor sweep failed",
|
|
46
|
+
detail: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
47
|
+
},
|
|
48
|
+
state,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=8-baseline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"8-baseline.js","sourceRoot":"","sources":["../../../src/init/phases/8-baseline.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,wBAAwB,EACxB,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAAiB;IACvD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAgC,CAAC;IAC3E,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAA6B,CAAC;IACrE,MAAM,KAAK,GAAiB,MAAM;QAChC,CAAC,CAAC;YACE,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB;YACtD,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS;YAClC,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,sBAAsB;YAC5D,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB;YAClD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB;SAC3C;QACH,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,SAAS,GAAG,wBAAwB,CACxC,CAAC,SAAS,EAAE,gBAAgB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAc,CAAC,CACjE,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAwB,MAAM,gBAAgB,CAAC;YACzD,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,YAAY,EAAE,KAAK;YACnB,SAAS;SACV,CAAC,CAAC;QACH,MAAM,IAAI,GAAe;YACvB,GAAG,KAAK;YACR,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE;SACpD,CAAC;QACF,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,SAAS,EAAE,UAAU;YACrB,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC;SAC1B,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE;gBACL,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE,8BAA8B;gBACvC,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACtE;YACD,KAAK;SACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { PHASE_IDS, type PhaseId, type PhaseState, type PhaseOutputs, type PhaseResult, type PhaseQuestion, type PhaseOption, type PhaseError, type ResumeReport, } from "./types.js";
|
|
2
|
+
export { INIT_STATE_PATH, phaseStateAbsPath, readPhaseState, writePhaseState, clearPhaseState, } from "./state-io.js";
|
|
3
|
+
export { freshPhaseState, resumePhases, nextPhaseAfter, advancePhase, } from "./orchestrator.js";
|
|
4
|
+
export { runPhase1Detect } from "./1-detect.js";
|
|
5
|
+
export { runPhase2Walker } from "./2-walker.js";
|
|
6
|
+
export { runPhase3Mapper } from "./3-mapper.js";
|
|
7
|
+
export { runPhase3bSeed } from "./3b-seed.js";
|
|
8
|
+
export { runPhase4Pilot } from "./4-pilot.js";
|
|
9
|
+
export { runPhase5Brand } from "./5-brand.js";
|
|
10
|
+
export { runPhase6DocsIngest } from "./6-docs-ingest.js";
|
|
11
|
+
export { runPhase7bSourceComments } from "./7b-source-comments.js";
|
|
12
|
+
export { runPhase7cRulesMerge } from "./7c-rules-merge.js";
|
|
13
|
+
export { runPhase8Baseline } from "./8-baseline.js";
|
|
14
|
+
export { runPhase10Strip } from "./10-strip.js";
|
|
15
|
+
export { runPhase12Multidev } from "./12-multidev.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { PHASE_IDS, } from "./types.js";
|
|
2
|
+
export { INIT_STATE_PATH, phaseStateAbsPath, readPhaseState, writePhaseState, clearPhaseState, } from "./state-io.js";
|
|
3
|
+
export { freshPhaseState, resumePhases, nextPhaseAfter, advancePhase, } from "./orchestrator.js";
|
|
4
|
+
export { runPhase1Detect } from "./1-detect.js";
|
|
5
|
+
export { runPhase2Walker } from "./2-walker.js";
|
|
6
|
+
export { runPhase3Mapper } from "./3-mapper.js";
|
|
7
|
+
export { runPhase3bSeed } from "./3b-seed.js";
|
|
8
|
+
export { runPhase4Pilot } from "./4-pilot.js";
|
|
9
|
+
export { runPhase5Brand } from "./5-brand.js";
|
|
10
|
+
export { runPhase6DocsIngest } from "./6-docs-ingest.js";
|
|
11
|
+
export { runPhase7bSourceComments } from "./7b-source-comments.js";
|
|
12
|
+
export { runPhase7cRulesMerge } from "./7c-rules-merge.js";
|
|
13
|
+
export { runPhase8Baseline } from "./8-baseline.js";
|
|
14
|
+
export { runPhase10Strip } from "./10-strip.js";
|
|
15
|
+
export { runPhase12Multidev } from "./12-multidev.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/init/phases/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GASV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator entry points for the MCP-native init pipeline.
|
|
3
|
+
*
|
|
4
|
+
* `resumePhases(repoRoot)` is the single readable surface for the
|
|
5
|
+
* cairn-adopt skill — it reads any persisted state, returns the next
|
|
6
|
+
* phase id, and (for fresh starts) constructs the initial PhaseState.
|
|
7
|
+
*
|
|
8
|
+
* Phase functions live in sibling files (one per id, see types.ts
|
|
9
|
+
* PHASE_IDS). The orchestrator does not invoke them directly; the
|
|
10
|
+
* skill driver calls each phase's MCP tool with the state returned
|
|
11
|
+
* from `resumePhases` and threads results forward.
|
|
12
|
+
*/
|
|
13
|
+
import { type PhaseId, type PhaseState, type ResumeReport } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* Construct the fresh state for a brand-new init run. No filesystem
|
|
16
|
+
* IO — the caller persists this via `writePhaseState` once phase
|
|
17
|
+
* 1-detect has created `.cairn/`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function freshPhaseState(repoRoot: string): PhaseState;
|
|
20
|
+
/**
|
|
21
|
+
* Read whatever init state is on disk for `repoRoot` and return the
|
|
22
|
+
* next phase the skill driver should invoke. If no state exists, the
|
|
23
|
+
* first phase becomes "ready".
|
|
24
|
+
*
|
|
25
|
+
* The persisted `state.currentPhase` IS the next phase to run:
|
|
26
|
+
* - On "complete", the phase function calls `advancePhase` to
|
|
27
|
+
* increment `currentPhase` to the successor before persisting.
|
|
28
|
+
* - On "needs_input", `currentPhase` stays put — the operator's
|
|
29
|
+
* answer feeds back into the same phase.
|
|
30
|
+
*
|
|
31
|
+
* The init-phases MCP tool clears the state file as soon as the final
|
|
32
|
+
* phase returns nextPhase=null, so a "done" report only fires when
|
|
33
|
+
* cleanup itself failed. We model that as "ready" pointing at the last
|
|
34
|
+
* phase id; the skill re-invokes (idempotent) and then clearPhaseState
|
|
35
|
+
* runs again.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resumePhases(repoRoot: string): ResumeReport;
|
|
38
|
+
/**
|
|
39
|
+
* Compute the phase id that follows `current` in PHASE_IDS, or null
|
|
40
|
+
* when `current` is already the last id. Pure function — useful from
|
|
41
|
+
* inside individual phase functions when stamping their PhaseResult.
|
|
42
|
+
*/
|
|
43
|
+
export declare function nextPhaseAfter(current: PhaseId): PhaseId | null;
|
|
44
|
+
/**
|
|
45
|
+
* Advance `state.currentPhase` to the next phase id. Returns a new
|
|
46
|
+
* state; does not mutate the input. Used by phase functions when
|
|
47
|
+
* stamping a "complete" result that hands off to the next phase.
|
|
48
|
+
*/
|
|
49
|
+
export declare function advancePhase(state: PhaseState): PhaseState;
|