@latysh-development/monolith 0.0.0-stage → 0.1.0-alpha.1
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/LICENSE +21 -0
- package/README.md +179 -2
- package/dist/brief/cli.d.ts +30 -0
- package/dist/brief/cli.d.ts.map +1 -0
- package/dist/brief/cli.js +85 -0
- package/dist/brief/collect.d.ts +17 -0
- package/dist/brief/collect.d.ts.map +1 -0
- package/dist/brief/collect.js +342 -0
- package/dist/brief/config.d.ts +40 -0
- package/dist/brief/config.d.ts.map +1 -0
- package/dist/brief/config.js +85 -0
- package/dist/brief/constants.d.ts +12 -0
- package/dist/brief/constants.d.ts.map +1 -0
- package/dist/brief/constants.js +11 -0
- package/dist/brief/docs.d.ts +53 -0
- package/dist/brief/docs.d.ts.map +1 -0
- package/dist/brief/docs.js +229 -0
- package/dist/brief/freshness.d.ts +104 -0
- package/dist/brief/freshness.d.ts.map +1 -0
- package/dist/brief/freshness.js +263 -0
- package/dist/brief/git-signals.d.ts +17 -0
- package/dist/brief/git-signals.d.ts.map +1 -0
- package/dist/brief/git-signals.js +101 -0
- package/dist/brief/index.d.ts +11 -0
- package/dist/brief/index.d.ts.map +1 -0
- package/dist/brief/index.js +5 -0
- package/dist/brief/reconcile.d.ts +75 -0
- package/dist/brief/reconcile.d.ts.map +1 -0
- package/dist/brief/reconcile.js +259 -0
- package/dist/brief/render.d.ts +67 -0
- package/dist/brief/render.d.ts.map +1 -0
- package/dist/brief/render.js +458 -0
- package/dist/brief/sanitize.d.ts +38 -0
- package/dist/brief/sanitize.d.ts.map +1 -0
- package/dist/brief/sanitize.js +48 -0
- package/dist/brief/selectors.d.ts +36 -0
- package/dist/brief/selectors.d.ts.map +1 -0
- package/dist/brief/selectors.js +75 -0
- package/dist/brief/story.d.ts +18 -0
- package/dist/brief/story.d.ts.map +1 -0
- package/dist/brief/story.js +59 -0
- package/dist/brief/types.d.ts +126 -0
- package/dist/brief/types.d.ts.map +1 -0
- package/dist/brief/types.js +11 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +199 -0
- package/dist/cli/init-args.d.ts +16 -0
- package/dist/cli/init-args.d.ts.map +1 -0
- package/dist/cli/init-args.js +24 -0
- package/dist/cli/ui-args.d.ts +23 -0
- package/dist/cli/ui-args.d.ts.map +1 -0
- package/dist/cli/ui-args.js +66 -0
- package/dist/cli/ui.d.ts +40 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/ui.js +180 -0
- package/dist/coordinatorium/checkpoint.d.ts +44 -0
- package/dist/coordinatorium/checkpoint.d.ts.map +1 -0
- package/dist/coordinatorium/checkpoint.js +124 -0
- package/dist/coordinatorium/cli.d.ts +39 -0
- package/dist/coordinatorium/cli.d.ts.map +1 -0
- package/dist/coordinatorium/cli.js +203 -0
- package/dist/coordinatorium/errors.d.ts +112 -0
- package/dist/coordinatorium/errors.d.ts.map +1 -0
- package/dist/coordinatorium/errors.js +145 -0
- package/dist/coordinatorium/index.d.ts +11 -0
- package/dist/coordinatorium/index.d.ts.map +1 -0
- package/dist/coordinatorium/index.js +5 -0
- package/dist/coordinatorium/lock.d.ts +187 -0
- package/dist/coordinatorium/lock.d.ts.map +1 -0
- package/dist/coordinatorium/lock.js +659 -0
- package/dist/coordinatorium/mission.d.ts +32 -0
- package/dist/coordinatorium/mission.d.ts.map +1 -0
- package/dist/coordinatorium/mission.js +87 -0
- package/dist/coordinatorium/state-keeper.d.ts +115 -0
- package/dist/coordinatorium/state-keeper.d.ts.map +1 -0
- package/dist/coordinatorium/state-keeper.js +396 -0
- package/dist/coordinatorium/types.d.ts +69 -0
- package/dist/coordinatorium/types.d.ts.map +1 -0
- package/dist/coordinatorium/types.js +27 -0
- package/dist/discovery/compose.d.ts +28 -0
- package/dist/discovery/compose.d.ts.map +1 -0
- package/dist/discovery/compose.js +159 -0
- package/dist/discovery/contracts.d.ts +211 -0
- package/dist/discovery/contracts.d.ts.map +1 -0
- package/dist/discovery/contracts.js +555 -0
- package/dist/discovery/docs.d.ts +278 -0
- package/dist/discovery/docs.d.ts.map +1 -0
- package/dist/discovery/docs.js +1182 -0
- package/dist/discovery/facts.d.ts +49 -0
- package/dist/discovery/facts.d.ts.map +1 -0
- package/dist/discovery/facts.js +541 -0
- package/dist/discovery/index.d.ts +8 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +9 -0
- package/dist/discovery/orchestrate.d.ts +35 -0
- package/dist/discovery/orchestrate.d.ts.map +1 -0
- package/dist/discovery/orchestrate.js +32 -0
- package/dist/discovery/render.d.ts +36 -0
- package/dist/discovery/render.d.ts.map +1 -0
- package/dist/discovery/render.js +278 -0
- package/dist/discovery/traverse.d.ts +197 -0
- package/dist/discovery/traverse.d.ts.map +1 -0
- package/dist/discovery/traverse.js +510 -0
- package/dist/durable/assess.d.ts +105 -0
- package/dist/durable/assess.d.ts.map +1 -0
- package/dist/durable/assess.js +239 -0
- package/dist/durable/canonical.d.ts +25 -0
- package/dist/durable/canonical.d.ts.map +1 -0
- package/dist/durable/canonical.js +78 -0
- package/dist/durable/cli.d.ts +37 -0
- package/dist/durable/cli.d.ts.map +1 -0
- package/dist/durable/cli.js +141 -0
- package/dist/durable/errors.d.ts +192 -0
- package/dist/durable/errors.d.ts.map +1 -0
- package/dist/durable/errors.js +323 -0
- package/dist/durable/fs-store.d.ts +254 -0
- package/dist/durable/fs-store.d.ts.map +1 -0
- package/dist/durable/fs-store.js +1493 -0
- package/dist/durable/index.d.ts +20 -0
- package/dist/durable/index.d.ts.map +1 -0
- package/dist/durable/index.js +13 -0
- package/dist/durable/log.d.ts +33 -0
- package/dist/durable/log.d.ts.map +1 -0
- package/dist/durable/log.js +157 -0
- package/dist/durable/memory-store.d.ts +51 -0
- package/dist/durable/memory-store.d.ts.map +1 -0
- package/dist/durable/memory-store.js +302 -0
- package/dist/durable/projection.d.ts +35 -0
- package/dist/durable/projection.d.ts.map +1 -0
- package/dist/durable/projection.js +328 -0
- package/dist/durable/prune-check.d.ts +34 -0
- package/dist/durable/prune-check.d.ts.map +1 -0
- package/dist/durable/prune-check.js +72 -0
- package/dist/durable/register.d.ts +100 -0
- package/dist/durable/register.d.ts.map +1 -0
- package/dist/durable/register.js +532 -0
- package/dist/durable/retention.d.ts +49 -0
- package/dist/durable/retention.d.ts.map +1 -0
- package/dist/durable/retention.js +59 -0
- package/dist/durable/runtime.d.ts +499 -0
- package/dist/durable/runtime.d.ts.map +1 -0
- package/dist/durable/runtime.js +1288 -0
- package/dist/durable/seams.d.ts +44 -0
- package/dist/durable/seams.d.ts.map +1 -0
- package/dist/durable/seams.js +21 -0
- package/dist/durable/testing.d.ts +11 -0
- package/dist/durable/testing.d.ts.map +1 -0
- package/dist/durable/testing.js +25 -0
- package/dist/durable/types.d.ts +442 -0
- package/dist/durable/types.d.ts.map +1 -0
- package/dist/durable/types.js +75 -0
- package/dist/graph/builder.d.ts +11 -0
- package/dist/graph/builder.d.ts.map +1 -0
- package/dist/graph/builder.js +153 -0
- package/dist/graph/identity.d.ts +37 -0
- package/dist/graph/identity.d.ts.map +1 -0
- package/dist/graph/identity.js +46 -0
- package/dist/graph/index.d.ts +7 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +3 -0
- package/dist/graph/resolver.d.ts +41 -0
- package/dist/graph/resolver.d.ts.map +1 -0
- package/dist/graph/resolver.js +36 -0
- package/dist/graph/types.d.ts +42 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +1 -0
- package/dist/http/index.d.ts +5 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +76 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +195 -0
- package/dist/http/ui-assets.d.ts +22 -0
- package/dist/http/ui-assets.d.ts.map +1 -0
- package/dist/http/ui-assets.js +100 -0
- package/dist/ideas/cli.d.ts +33 -0
- package/dist/ideas/cli.d.ts.map +1 -0
- package/dist/ideas/cli.js +158 -0
- package/dist/ideas/format.d.ts +38 -0
- package/dist/ideas/format.d.ts.map +1 -0
- package/dist/ideas/format.js +194 -0
- package/dist/ideas/index.d.ts +6 -0
- package/dist/ideas/index.d.ts.map +1 -0
- package/dist/ideas/index.js +3 -0
- package/dist/ideas/store.d.ts +55 -0
- package/dist/ideas/store.d.ts.map +1 -0
- package/dist/ideas/store.js +262 -0
- package/dist/ideas/types.d.ts +54 -0
- package/dist/ideas/types.d.ts.map +1 -0
- package/dist/ideas/types.js +26 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/init/index.d.ts +12 -0
- package/dist/init/index.d.ts.map +1 -0
- package/dist/init/index.js +90 -0
- package/dist/init/prompts.d.ts +3 -0
- package/dist/init/prompts.d.ts.map +1 -0
- package/dist/init/prompts.js +47 -0
- package/dist/init/scaffold.d.ts +29 -0
- package/dist/init/scaffold.d.ts.map +1 -0
- package/dist/init/scaffold.js +208 -0
- package/dist/init/types.d.ts +14 -0
- package/dist/init/types.d.ts.map +1 -0
- package/dist/init/types.js +1 -0
- package/dist/managed/index.d.ts +73 -0
- package/dist/managed/index.d.ts.map +1 -0
- package/dist/managed/index.js +222 -0
- package/dist/readmodel/dashboard.d.ts +40 -0
- package/dist/readmodel/dashboard.d.ts.map +1 -0
- package/dist/readmodel/dashboard.js +236 -0
- package/dist/readmodel/index.d.ts +3 -0
- package/dist/readmodel/index.d.ts.map +1 -0
- package/dist/readmodel/index.js +1 -0
- package/dist/readmodel/types.d.ts +104 -0
- package/dist/readmodel/types.d.ts.map +1 -0
- package/dist/readmodel/types.js +15 -0
- package/dist/root/index.d.ts +186 -0
- package/dist/root/index.d.ts.map +1 -0
- package/dist/root/index.js +430 -0
- package/dist/root/safe-write.d.ts +268 -0
- package/dist/root/safe-write.d.ts.map +1 -0
- package/dist/root/safe-write.js +966 -0
- package/dist/root/write-artifacts.d.ts +20 -0
- package/dist/root/write-artifacts.d.ts.map +1 -0
- package/dist/root/write-artifacts.js +42 -0
- package/dist/scriptorium/compile.d.ts +4 -0
- package/dist/scriptorium/compile.d.ts.map +1 -0
- package/dist/scriptorium/compile.js +185 -0
- package/dist/scriptorium/frontmatter.d.ts +13 -0
- package/dist/scriptorium/frontmatter.d.ts.map +1 -0
- package/dist/scriptorium/frontmatter.js +90 -0
- package/dist/scriptorium/index.d.ts +3 -0
- package/dist/scriptorium/index.d.ts.map +1 -0
- package/dist/scriptorium/index.js +1 -0
- package/dist/scriptorium/markdown.d.ts +31 -0
- package/dist/scriptorium/markdown.d.ts.map +1 -0
- package/dist/scriptorium/markdown.js +88 -0
- package/dist/scriptorium/types.d.ts +78 -0
- package/dist/scriptorium/types.d.ts.map +1 -0
- package/dist/scriptorium/types.js +1 -0
- package/dist/types/enforcement.d.ts +11 -0
- package/dist/types/enforcement.d.ts.map +1 -0
- package/dist/types/enforcement.js +1 -0
- package/dist/types/integrity.d.ts +33 -0
- package/dist/types/integrity.d.ts.map +1 -0
- package/dist/types/integrity.js +1 -0
- package/dist/types/project-definition.d.ts +30 -0
- package/dist/types/project-definition.d.ts.map +1 -0
- package/dist/types/project-definition.js +1 -0
- package/dist/ui/assets/cosmic-glass-bg-Dwx47zPu.webp +0 -0
- package/dist/ui/assets/index-C4NhMaq7.js +28 -0
- package/dist/ui/assets/index-DMZ7ZvZY.css +1 -0
- package/dist/ui/index.html +13 -0
- package/dist/update/cli.d.ts +8 -0
- package/dist/update/cli.d.ts.map +1 -0
- package/dist/update/cli.js +115 -0
- package/dist/update/index.d.ts +78 -0
- package/dist/update/index.d.ts.map +1 -0
- package/dist/update/index.js +285 -0
- package/dist/validate/index.d.ts +6 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +214 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1 -0
- package/package.json +67 -4
- package/templates/.gitkeep +0 -0
- package/templates/default-instance/instruction/.cursorrules +59 -0
- package/templates/default-instance/instruction/.windsurfrules +59 -0
- package/templates/default-instance/instruction/CLAUDE.md +57 -0
- package/templates/default-instance/managed/agent.md +20 -0
- package/templates/default-instance/managed/bootstrap.md +7 -0
- package/templates/default-instance/managed/index-idea.md +5 -0
- package/templates/default-instance/managed/routing-idea.md +14 -0
- package/templates/default-instance/monolith/AGENT.md +1 -0
- package/templates/default-instance/monolith/context/boot/HANDOFF.md +49 -0
- package/templates/default-instance/monolith/context/boot/WORK_SESSION.md +30 -0
- package/templates/default-instance/monolith/context/execution/current-state.md +30 -0
- package/templates/default-instance/monolith/context/maps/dependency-map.md +38 -0
- package/templates/default-instance/monolith/context/maps/project-map.md +85 -0
- package/templates/default-instance/monolith/context/maps/roadmap-index.md +41 -0
- package/templates/default-instance/monolith/context/maps/routing-map.md +151 -0
- package/templates/default-instance/monolith/context/maps/semantic-map.md +75 -0
- package/templates/default-instance/monolith/context/models/model-registry.md +37 -0
- package/templates/default-instance/monolith/context/models/privacy-classification.md +35 -0
- package/templates/default-instance/monolith/context/templates/plan-template.md +56 -0
- package/templates/default-instance/monolith/governance/README.md +29 -0
- package/templates/default-instance/monolith/governance/RULE_SCHEMA.md +58 -0
- package/templates/default-instance/monolith/learning/INDEX.md +48 -0
- package/templates/default-instance/monolith/learning/injection-map.md +49 -0
- package/templates/default-instance/monolith/learning/taxonomy.md +30 -0
- package/templates/default-instance/monolith/memory/errors/README.md +26 -0
- package/templates/default-instance/monolith/memory/errors/SCHEMA.md +47 -0
- package/templates/default-instance/monolith/memory/errors/TAXONOMY.md +27 -0
- package/templates/default-instance/monolith/memory/long-term/architecture-principles.md +31 -0
- package/templates/default-instance/monolith/memory/long-term/decisions.md +36 -0
- package/templates/default-instance/monolith/memory/long-term/execution-history.md +20 -0
- package/templates/default-instance/monolith/memory/long-term/tech-debt.md +25 -0
- package/templates/default-instance/monolith/memory/working/active.md +41 -0
- package/templates/default-instance/monolith/memory/working/governance-result.md +0 -0
- package/templates/default-instance/monolith/memory/working/integrity-result.md +0 -0
- package/templates/default-instance/monolith/memory/working/story-index.md +28 -0
- package/templates/default-instance/monolith/protocols/boot/boot-sequence.md +59 -0
- package/templates/default-instance/monolith/protocols/cognition/cognitive-modes.md +90 -0
- package/templates/default-instance/monolith/protocols/cognition/dry-run.md +56 -0
- package/templates/default-instance/monolith/protocols/cognition/execution-trace-format.md +52 -0
- package/templates/default-instance/monolith/protocols/cognition/semantic-planning.md +51 -0
- package/templates/default-instance/monolith/protocols/execution/hybrid-execution.md +37 -0
- package/templates/default-instance/monolith/protocols/execution/local-llm-governance.md +42 -0
- package/templates/default-instance/monolith/protocols/governance/command-policy.md +51 -0
- package/templates/default-instance/monolith/protocols/governance/core-invariants.md +40 -0
- package/templates/default-instance/monolith/protocols/governance/memory-governance.md +54 -0
- package/templates/default-instance/monolith/protocols/governance/metadata-schema.md +62 -0
- package/templates/default-instance/monolith/protocols/governance/skills.md +53 -0
- package/templates/default-instance/monolith/protocols/governance/work-session.md +46 -0
- package/templates/default-instance/monolith/skills/INDEX.md +32 -0
- package/templates/default-instance/monolith/skills/current-status/SKILL.md +47 -0
- package/templates/default-instance/monolith/skills/finalize-story/SKILL.md +86 -0
- package/templates/default-instance/monolith/skills/global-status/SKILL.md +56 -0
- package/templates/default-instance/monolith/skills/idea-capture/SKILL.md +157 -0
- package/templates/default-instance/monolith/skills/self-improvement/SKILL.md +77 -0
- package/templates/default-instance/monolith/state.json +11 -0
- package/templates/default-instance/monolith/tests/INDEX.md +57 -0
- package/templates/default-instance/monolith/tests/scenarios/architecture-review.md +32 -0
- package/templates/default-instance/monolith/tests/scenarios/debug-failure.md +32 -0
- package/templates/default-instance/monolith/tests/scenarios/dry-run-activation.md +33 -0
- package/templates/default-instance/monolith/tests/scenarios/execution-trace-verification.md +31 -0
- package/templates/default-instance/monolith/tests/scenarios/finalize-story.md +35 -0
- package/templates/default-instance/monolith/tests/scenarios/implement-feature.md +36 -0
- package/templates/default-instance/monolith/tests/scenarios/local-llm-delegation.md +31 -0
- package/templates/default-instance/monolith/tests/scenarios/planning-request.md +32 -0
- package/templates/default-instance/monolith/tests/scenarios/sensitive-context-task.md +30 -0
- package/templates/default-instance/monolith/tests/scenarios/validator-verification.md +33 -0
- package/templates/default-instance/monolith/tests/validation/expected-behavior.md +70 -0
- package/templates/default-instance/monolith/tests/validators/INDEX.md +17 -0
- package/templates/default-instance/monolith/tests/validators/delegation-semantics.md +22 -0
- package/templates/default-instance/monolith/tests/validators/mode-consistency.md +25 -0
- package/templates/default-instance/monolith/tests/validators/privacy-routing.md +23 -0
- package/templates/default-instance/monolith/tests/validators/protocol-references.md +27 -0
- package/templates/default-instance/monolith/tests/validators/routing-integrity.md +30 -0
- package/templates/default-instance/projectroot/AGENTS.md +111 -0
- package/templates/default-instance/projectroot/monolith.config.json +32 -0
- package/templates/default-instance/projectroot/project.definition.mjs.template +41 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @latysh-development/monolith — Public API surface
|
|
3
|
+
*
|
|
4
|
+
* This file is the package entrypoint. Exports grow here as Kernel modules
|
|
5
|
+
* are extracted from project instances into this package.
|
|
6
|
+
*
|
|
7
|
+
* Current state: Phase 6 — validate implemented; Scriptorium (Story 1.2) and
|
|
8
|
+
* Explicit Relationship Graph (Story 1.3) integrated.
|
|
9
|
+
* See Phase 7+ roadmap for Kernel extraction.
|
|
10
|
+
*
|
|
11
|
+
* Webway (the frequency-based "meaning linker" prototype from Story 1.1) was
|
|
12
|
+
* extracted into its own repository: https://github.com/Demion-L/webway —
|
|
13
|
+
* it was an independent research track with zero runtime coupling to
|
|
14
|
+
* Scriptorium/Graph, see docs/webway-v0.md for the historical record.
|
|
15
|
+
*/
|
|
16
|
+
export { MONOLITH_VERSION } from './version.js';
|
|
17
|
+
export { runInit } from './init/index.js';
|
|
18
|
+
export { compileMarkdownArtifact, isStructuralHeadingNoise } from './scriptorium/index.js';
|
|
19
|
+
export { buildGraph, buildObjectIndex, resolveRef, makeRef, parseRef, isValidIdentifier } from './graph/index.js';
|
|
20
|
+
export { createInitialState, CoordinatoriumError, StateCorruptedError, StateSchemaError, LockTimeoutError, MissionNotFoundError, InvalidTransitionError, ValidationError, readState, mutateState, projectTarget, trustedDirectoryTarget, startMission, listMissions, getMission, finishMission, } from './coordinatorium/index.js';
|
|
21
|
+
// Safe writes — explicit write scope and publication states (SEC-001B.2, ADR-012)
|
|
22
|
+
export { SafeWriteError } from './root/index.js';
|
|
23
|
+
// Durable State — domain-neutral, crash-safe execution record for long-running agentic tasks (ADR-017).
|
|
24
|
+
// Namespaced: its error taxonomy deliberately shares names (e.g. ValidationError) with Coordinatorium's.
|
|
25
|
+
// EXPERIMENTAL. Security acceptance pending (see AGENTS.md → Durable State); the API may change in any alpha.
|
|
26
|
+
export * as durable from './durable/index.js';
|
|
27
|
+
// Manual Idea Capture (IDEA-001A) — deferred thoughts saved as Markdown under <monolithRoot>/memory/long-term/ideas/.
|
|
28
|
+
export * as ideas from './ideas/index.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InitOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when `monolith init` would overwrite existing tracked files.
|
|
4
|
+
* Raised strictly before any write — see planScaffoldConflicts. Carries a
|
|
5
|
+
* non-zero exit via the CLI's top-level main().catch handler.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InitConflictError extends Error {
|
|
8
|
+
readonly conflicts: string[];
|
|
9
|
+
constructor(conflicts: string[]);
|
|
10
|
+
}
|
|
11
|
+
export declare function runInit(options?: InitOptions): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/init/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;gBAEjB,SAAS,EAAE,MAAM,EAAE;CAmBhC;AAED,wBAAsB,OAAO,CAAC,OAAO,GAAE,WAA0C,GAAG,OAAO,CAAC,IAAI,CAAC,CA+DhG"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { promptProjectConfig } from './prompts.js';
|
|
4
|
+
import { scaffoldInstance, planScaffoldConflicts } from './scaffold.js';
|
|
5
|
+
import { reportWriteWarning } from '../root/index.js';
|
|
6
|
+
const CONFLICT_LIST_LIMIT = 20;
|
|
7
|
+
/**
|
|
8
|
+
* Thrown when `monolith init` would overwrite existing tracked files.
|
|
9
|
+
* Raised strictly before any write — see planScaffoldConflicts. Carries a
|
|
10
|
+
* non-zero exit via the CLI's top-level main().catch handler.
|
|
11
|
+
*/
|
|
12
|
+
export class InitConflictError extends Error {
|
|
13
|
+
conflicts;
|
|
14
|
+
constructor(conflicts) {
|
|
15
|
+
const shown = conflicts.slice(0, CONFLICT_LIST_LIMIT);
|
|
16
|
+
const more = conflicts.length - shown.length;
|
|
17
|
+
const list = shown.map((c) => ` - ${c}`).join('\n');
|
|
18
|
+
super(`Refusing to initialize: ${conflicts.length} existing or unsafe path(s) (already present, or a symlink / special file that must not be written through):\n` +
|
|
19
|
+
`${list}\n` +
|
|
20
|
+
(more > 0 ? ` ...and ${more} more\n` : '') +
|
|
21
|
+
'\n' +
|
|
22
|
+
' monolith init always scaffolds the current working directory and never\n' +
|
|
23
|
+
' overwrites existing tracked files (re-running it is not an upgrade/force\n' +
|
|
24
|
+
' mechanism). --yes only skips interactive prompts for a clean directory;\n' +
|
|
25
|
+
' it does not authorize overwriting existing data.\n' +
|
|
26
|
+
' Remove, rename, or back up the conflicting file(s) yourself, or run init\n' +
|
|
27
|
+
' in an empty directory, then re-run.');
|
|
28
|
+
this.name = 'InitConflictError';
|
|
29
|
+
this.conflicts = conflicts;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function runInit(options = { targetDir: process.cwd() }) {
|
|
33
|
+
const targetDir = resolve(options.targetDir);
|
|
34
|
+
console.log(' Initializing MONOLITH instance...');
|
|
35
|
+
console.log('');
|
|
36
|
+
let config;
|
|
37
|
+
if (options.yes) {
|
|
38
|
+
// Non-interactive: use all defaults
|
|
39
|
+
const { basename } = await import('path');
|
|
40
|
+
config = {
|
|
41
|
+
projectName: basename(targetDir),
|
|
42
|
+
language: 'typescript',
|
|
43
|
+
packageManager: 'pnpm',
|
|
44
|
+
aiTool: 'claude',
|
|
45
|
+
finalizationProtocol: 'finalize-story',
|
|
46
|
+
protocols: ['finalize-story', 'failure-memory-logging', 'governance-evaluation', 'integrity-verification'],
|
|
47
|
+
monolithRoot: '.monolith',
|
|
48
|
+
};
|
|
49
|
+
console.log(` Project: ${config.projectName} (defaults applied)`);
|
|
50
|
+
console.log('');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
config = await promptProjectConfig();
|
|
54
|
+
}
|
|
55
|
+
// Preflight: must run — and find zero conflicts — before any write, so a
|
|
56
|
+
// conflict is never discovered after half the instance has already been
|
|
57
|
+
// scaffolded (see LESSON-2026-0006 / TD-007).
|
|
58
|
+
const conflicts = planScaffoldConflicts(targetDir, config);
|
|
59
|
+
if (conflicts.length > 0) {
|
|
60
|
+
throw new InitConflictError(conflicts);
|
|
61
|
+
}
|
|
62
|
+
console.log(' Scaffolding instance...');
|
|
63
|
+
console.log('');
|
|
64
|
+
const result = await scaffoldInstance(targetDir, config);
|
|
65
|
+
for (const w of result.warnings)
|
|
66
|
+
reportWriteWarning(w);
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(' ✅ MONOLITH instance initialized!');
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log(` Project: ${config.projectName}`);
|
|
71
|
+
console.log(` Root: ${config.monolithRoot}/`);
|
|
72
|
+
console.log(` Files created: ${result.filesCreated}`);
|
|
73
|
+
console.log('');
|
|
74
|
+
const instructionFileMap = {
|
|
75
|
+
claude: 'CLAUDE.md',
|
|
76
|
+
cursor: '.cursorrules',
|
|
77
|
+
windsurf: '.windsurfrules',
|
|
78
|
+
};
|
|
79
|
+
const instructionFile = instructionFileMap[config.aiTool] ?? 'AGENTS.md';
|
|
80
|
+
console.log(` AI tool: ${config.aiTool} → ${instructionFile}`);
|
|
81
|
+
console.log('');
|
|
82
|
+
console.log(' Next steps:');
|
|
83
|
+
console.log(` 1. Edit ${instructionFile} — verify skill triggers and paths`);
|
|
84
|
+
console.log(' 2. Edit AGENTS.md — add project description');
|
|
85
|
+
console.log(` 3. Edit ${config.monolithRoot}/context/maps/project-map.md — describe your structure`);
|
|
86
|
+
console.log(` 4. Edit ${config.monolithRoot}/context/maps/roadmap-index.md — add your phases`);
|
|
87
|
+
console.log(` 5. Edit ${config.monolithRoot}/protocols/governance/core-invariants.md — set Current Focus`);
|
|
88
|
+
console.log(` 6. Start first story: edit ${config.monolithRoot}/memory/working/active.md`);
|
|
89
|
+
console.log('');
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/init/prompts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+BhD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CAuClE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { createInterface } from 'readline';
|
|
3
|
+
import { basename } from 'path';
|
|
4
|
+
function createPrompter() {
|
|
5
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
6
|
+
const ask = (question, defaultValue) => new Promise((resolve) => {
|
|
7
|
+
const hint = defaultValue ? ` (${defaultValue})` : '';
|
|
8
|
+
rl.question(` ${question}${hint}: `, (answer) => {
|
|
9
|
+
resolve(answer.trim() || defaultValue || '');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
const askChoice = (question, choices, defaultChoice) => new Promise((resolve) => {
|
|
13
|
+
const choiceStr = choices.map((c) => (c === defaultChoice ? `[${c}]` : c)).join(' | ');
|
|
14
|
+
rl.question(` ${question} (${choiceStr}): `, (answer) => {
|
|
15
|
+
const trimmed = answer.trim().toLowerCase();
|
|
16
|
+
if (!trimmed)
|
|
17
|
+
return resolve(defaultChoice);
|
|
18
|
+
const match = choices.find((c) => c.toLowerCase() === trimmed);
|
|
19
|
+
resolve(match ?? defaultChoice);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return { ask, askChoice, close: () => rl.close() };
|
|
23
|
+
}
|
|
24
|
+
export async function promptProjectConfig() {
|
|
25
|
+
const p = createPrompter();
|
|
26
|
+
console.log('');
|
|
27
|
+
const projectName = await p.ask('Project name', basename(process.cwd()));
|
|
28
|
+
const language = await p.askChoice('Primary language', ['typescript', 'javascript', 'python', 'other'], 'typescript');
|
|
29
|
+
const packageManager = await p.askChoice('Package manager', ['pnpm', 'npm', 'yarn', 'other'], 'pnpm');
|
|
30
|
+
const aiTool = await p.askChoice('AI assistant tool', ['claude', 'cursor', 'windsurf', 'other'], 'claude');
|
|
31
|
+
p.close();
|
|
32
|
+
console.log('');
|
|
33
|
+
return {
|
|
34
|
+
projectName,
|
|
35
|
+
language,
|
|
36
|
+
packageManager,
|
|
37
|
+
aiTool,
|
|
38
|
+
finalizationProtocol: 'finalize-story',
|
|
39
|
+
protocols: [
|
|
40
|
+
'finalize-story',
|
|
41
|
+
'failure-memory-logging',
|
|
42
|
+
'governance-evaluation',
|
|
43
|
+
'integrity-verification',
|
|
44
|
+
],
|
|
45
|
+
monolithRoot: '.monolith',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ProjectConfig } from './types.js';
|
|
2
|
+
import { type WriteWarning } from '../root/index.js';
|
|
3
|
+
export declare const TEMPLATES_ROOT: string;
|
|
4
|
+
type Vars = Record<string, string>;
|
|
5
|
+
export declare function substitute(content: string, vars: Vars): string;
|
|
6
|
+
export interface ScaffoldResult {
|
|
7
|
+
filesCreated: number;
|
|
8
|
+
dirsCreated: string[];
|
|
9
|
+
/** Non-fatal write findings (e.g. best-effort platform). */
|
|
10
|
+
warnings: WriteWarning[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Preflight: compute every tracked template target path scaffoldInstance
|
|
14
|
+
* would write, and return the ones that already exist on disk — or that cannot
|
|
15
|
+
* be written safely (a symlink, including a dangling one, at the target or in
|
|
16
|
+
* a parent component; a FIFO or other special file). Must be called — and
|
|
17
|
+
* found empty — before scaffoldInstance runs, so a conflict is caught before
|
|
18
|
+
* any file is written (no half-scaffolded instance). This is advice for a
|
|
19
|
+
* clean error message; the exclusive creation in scaffoldInstance is the
|
|
20
|
+
* authoritative check.
|
|
21
|
+
*
|
|
22
|
+
* `state.json` is intentionally excluded when it is a regular file:
|
|
23
|
+
* scaffoldInstance never overwrites it (mutable Coordinatorium runtime data,
|
|
24
|
+
* ADR-008), so its presence is not a conflict. A symlink there still is.
|
|
25
|
+
*/
|
|
26
|
+
export declare function planScaffoldConflicts(targetDir: string, config: ProjectConfig): string[];
|
|
27
|
+
export declare function scaffoldInstance(targetDir: string, config: ProjectConfig): Promise<ScaffoldResult>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../../src/init/scaffold.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAQL,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAY1B,eAAO,MAAM,cAAc,QAAkE,CAAC;AAE9F,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnC,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAE9D;AAgHD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAqCxF;AAED,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,cAAc,CAAC,CA4EzB"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
3
|
+
import { join, dirname, resolve, relative, basename } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { BLOCK_IDS, blockBody, placeholderFor, renderBlock } from '../managed/index.js';
|
|
6
|
+
import { SafeWriteError, createFile, openParent, probeTarget, projectBoundary, resolveMonolithRootValue, } from '../root/index.js';
|
|
7
|
+
const INSTRUCTION_FILE_MAP = {
|
|
8
|
+
claude: 'CLAUDE.md',
|
|
9
|
+
cursor: '.cursorrules',
|
|
10
|
+
windsurf: '.windsurfrules',
|
|
11
|
+
};
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
// Works both from dist/init/ (compiled) and src/init/ (tsx)
|
|
15
|
+
export const TEMPLATES_ROOT = resolve(__dirname, '..', '..', 'templates', 'default-instance');
|
|
16
|
+
export function substitute(content, vars) {
|
|
17
|
+
return content.replace(/\{\{([A-Z_]+)\}\}/g, (_, key) => vars[key] ?? `{{${key}}}`);
|
|
18
|
+
}
|
|
19
|
+
function stripTemplateSuffix(p) {
|
|
20
|
+
return p.endsWith('.template') ? p.slice(0, -'.template'.length) : p;
|
|
21
|
+
}
|
|
22
|
+
/** Documents follow the umask (as before); the runtime state file is owner-only. */
|
|
23
|
+
function writeNew(w, targetPath, content, asState) {
|
|
24
|
+
const parent = openParent(w.boundary, dirname(targetPath), { create: true });
|
|
25
|
+
const outcome = createFile(parent, basename(targetPath), content, {
|
|
26
|
+
...(asState ? { mode: 0o600 } : { mode: 0o666, exactMode: false }),
|
|
27
|
+
durability: 'file',
|
|
28
|
+
});
|
|
29
|
+
w.warnings.push(...outcome.warnings);
|
|
30
|
+
w.created++;
|
|
31
|
+
}
|
|
32
|
+
function copyTemplate(w, templatePath, targetPath, vars, asState = false) {
|
|
33
|
+
writeNew(w, targetPath, substitute(readFileSync(templatePath, 'utf8'), vars), asState);
|
|
34
|
+
w.templates++;
|
|
35
|
+
}
|
|
36
|
+
function walkDir(dir) {
|
|
37
|
+
const results = [];
|
|
38
|
+
if (!existsSync(dir))
|
|
39
|
+
return results;
|
|
40
|
+
for (const entry of readdirSync(dir)) {
|
|
41
|
+
const full = join(dir, entry);
|
|
42
|
+
if (statSync(full).isDirectory()) {
|
|
43
|
+
results.push(...walkDir(full));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
results.push(full);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return results;
|
|
50
|
+
}
|
|
51
|
+
function buildVars(config) {
|
|
52
|
+
const r = config.monolithRoot;
|
|
53
|
+
return {
|
|
54
|
+
PROJECT_NAME: config.projectName,
|
|
55
|
+
LANGUAGE: config.language,
|
|
56
|
+
PACKAGE_MANAGER: config.packageManager,
|
|
57
|
+
AI_TOOL: config.aiTool,
|
|
58
|
+
MONOLITH_ROOT: r,
|
|
59
|
+
FINALIZATION_PROTOCOL: config.finalizationProtocol,
|
|
60
|
+
PROTOCOLS_JSON: JSON.stringify(config.protocols, null, 2)
|
|
61
|
+
.split('\n')
|
|
62
|
+
.join('\n '),
|
|
63
|
+
MISTAKE_ROOTS_JSON: JSON.stringify([`${r}/learning/mistakes`, `${r}/memory/errors`], null, 2)
|
|
64
|
+
.split('\n')
|
|
65
|
+
.join('\n '),
|
|
66
|
+
DRIFT_LOG_PATH: `${r}/enforcement/drift-log.json`,
|
|
67
|
+
// Same managed blocks `monolith update` writes into existing instances.
|
|
68
|
+
...Object.fromEntries(BLOCK_IDS.map((id) => [placeholderFor(id), renderBlock(id, blockBody(id, r)).replace(/\n$/, '')])),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Relative to config.monolithRoot (`r`). Shared between createEmptyDirs
|
|
72
|
+
// (what init writes) and planScaffoldConflicts (what init must refuse to
|
|
73
|
+
// overwrite) so the two can never drift apart — see gitkeepTargets().
|
|
74
|
+
const GITKEEP_DIRS = [
|
|
75
|
+
'memory/working/phases',
|
|
76
|
+
'memory/execution/traces',
|
|
77
|
+
'memory/long-term/ideas',
|
|
78
|
+
'protocols/engineering',
|
|
79
|
+
'learning/mistakes/architecture',
|
|
80
|
+
'learning/mistakes/dependencies',
|
|
81
|
+
'learning/mistakes/nonexistent-api',
|
|
82
|
+
'learning/mistakes/context-sync',
|
|
83
|
+
'learning/mistakes/workflow',
|
|
84
|
+
'learning/mistakes/typescript',
|
|
85
|
+
'learning/mistakes/documentation',
|
|
86
|
+
];
|
|
87
|
+
/** `.gitkeep` paths (relative to targetDir) that init creates for `r`. */
|
|
88
|
+
function gitkeepTargets(r) {
|
|
89
|
+
return GITKEEP_DIRS.map((rel) => `${r}/${rel}/.gitkeep`);
|
|
90
|
+
}
|
|
91
|
+
function createEmptyDirs(w, targetRoot, r) {
|
|
92
|
+
for (const rel of GITKEEP_DIRS) {
|
|
93
|
+
const full = join(targetRoot, r, rel);
|
|
94
|
+
// An existing .gitkeep (possibly user-authored, non-empty) must never be
|
|
95
|
+
// overwritten. planScaffoldConflicts() is expected to have already
|
|
96
|
+
// refused the run in this case; this is the authoritative second guard:
|
|
97
|
+
// creation is exclusive, so an existing entry of any kind is an error.
|
|
98
|
+
writeNew(w, join(full, '.gitkeep'), '', false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Preflight: compute every tracked template target path scaffoldInstance
|
|
103
|
+
* would write, and return the ones that already exist on disk — or that cannot
|
|
104
|
+
* be written safely (a symlink, including a dangling one, at the target or in
|
|
105
|
+
* a parent component; a FIFO or other special file). Must be called — and
|
|
106
|
+
* found empty — before scaffoldInstance runs, so a conflict is caught before
|
|
107
|
+
* any file is written (no half-scaffolded instance). This is advice for a
|
|
108
|
+
* clean error message; the exclusive creation in scaffoldInstance is the
|
|
109
|
+
* authoritative check.
|
|
110
|
+
*
|
|
111
|
+
* `state.json` is intentionally excluded when it is a regular file:
|
|
112
|
+
* scaffoldInstance never overwrites it (mutable Coordinatorium runtime data,
|
|
113
|
+
* ADR-008), so its presence is not a conflict. A symlink there still is.
|
|
114
|
+
*/
|
|
115
|
+
export function planScaffoldConflicts(targetDir, config) {
|
|
116
|
+
// SEC-001A: the programmatic API enforces the same root policy as the CLI.
|
|
117
|
+
const r = resolveMonolithRootValue(targetDir, config.monolithRoot).monolithRoot;
|
|
118
|
+
const conflicts = [];
|
|
119
|
+
const boundary = projectBoundary(targetDir);
|
|
120
|
+
const check = (targetPath, regularFileIsFine = false) => {
|
|
121
|
+
const probe = probeTarget(boundary, targetPath);
|
|
122
|
+
if (probe.state === 'free')
|
|
123
|
+
return;
|
|
124
|
+
if (probe.state === 'exists' && regularFileIsFine)
|
|
125
|
+
return;
|
|
126
|
+
const rel = relative(targetDir, probe.path);
|
|
127
|
+
if (!conflicts.includes(rel))
|
|
128
|
+
conflicts.push(rel);
|
|
129
|
+
};
|
|
130
|
+
const projectrootTemplates = join(TEMPLATES_ROOT, 'projectroot');
|
|
131
|
+
if (existsSync(projectrootTemplates)) {
|
|
132
|
+
for (const tplFile of walkDir(projectrootTemplates)) {
|
|
133
|
+
const relPath = relative(projectrootTemplates, tplFile);
|
|
134
|
+
check(join(targetDir, stripTemplateSuffix(relPath)));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const monolithTemplates = join(TEMPLATES_ROOT, 'monolith');
|
|
138
|
+
if (existsSync(monolithTemplates)) {
|
|
139
|
+
for (const tplFile of walkDir(monolithTemplates)) {
|
|
140
|
+
const relPath = relative(monolithTemplates, tplFile);
|
|
141
|
+
const strippedRelPath = stripTemplateSuffix(relPath);
|
|
142
|
+
check(join(targetDir, r, strippedRelPath), strippedRelPath === 'state.json');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const instructionFileName = INSTRUCTION_FILE_MAP[config.aiTool];
|
|
146
|
+
if (instructionFileName)
|
|
147
|
+
check(join(targetDir, instructionFileName));
|
|
148
|
+
for (const rel of gitkeepTargets(r))
|
|
149
|
+
check(join(targetDir, rel));
|
|
150
|
+
return conflicts;
|
|
151
|
+
}
|
|
152
|
+
export async function scaffoldInstance(targetDir, config) {
|
|
153
|
+
// SEC-001A: validate before any write; throws RootContainmentError.
|
|
154
|
+
const r = resolveMonolithRootValue(targetDir, config.monolithRoot).monolithRoot;
|
|
155
|
+
const vars = buildVars({ ...config, monolithRoot: r });
|
|
156
|
+
const dirsCreated = [];
|
|
157
|
+
// `targetDir` is the project root the user pointed init at (it must exist,
|
|
158
|
+
// as resolveMonolithRootValue already requires). Everything below it is checked.
|
|
159
|
+
const w = { boundary: projectBoundary(targetDir), warnings: [], created: 0, templates: 0 };
|
|
160
|
+
try {
|
|
161
|
+
// --- Project root files ---
|
|
162
|
+
const projectrootTemplates = join(TEMPLATES_ROOT, 'projectroot');
|
|
163
|
+
if (existsSync(projectrootTemplates)) {
|
|
164
|
+
for (const tplFile of walkDir(projectrootTemplates)) {
|
|
165
|
+
const relPath = relative(projectrootTemplates, tplFile);
|
|
166
|
+
copyTemplate(w, tplFile, join(targetDir, stripTemplateSuffix(relPath)), vars);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// --- Monolith instance files ---
|
|
170
|
+
const monolithTemplates = join(TEMPLATES_ROOT, 'monolith');
|
|
171
|
+
if (existsSync(monolithTemplates)) {
|
|
172
|
+
for (const tplFile of walkDir(monolithTemplates)) {
|
|
173
|
+
const relPath = relative(monolithTemplates, tplFile);
|
|
174
|
+
const strippedRelPath = stripTemplateSuffix(relPath);
|
|
175
|
+
const targetPath = join(targetDir, r, strippedRelPath);
|
|
176
|
+
const isState = strippedRelPath === 'state.json';
|
|
177
|
+
// Coordinatorium state (ADR-008) is mutable runtime data, not a
|
|
178
|
+
// document template — re-running init must never clobber missions
|
|
179
|
+
// an existing instance has already recorded. Only a regular file is
|
|
180
|
+
// left alone; a symlink or special file there is still refused.
|
|
181
|
+
if (isState && probeTarget(w.boundary, targetPath).state === 'exists')
|
|
182
|
+
continue;
|
|
183
|
+
copyTemplate(w, tplFile, targetPath, vars, isState);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// --- AI tool instruction file (CLAUDE.md / .cursorrules / .windsurfrules) ---
|
|
187
|
+
const instructionFileName = INSTRUCTION_FILE_MAP[config.aiTool];
|
|
188
|
+
if (instructionFileName) {
|
|
189
|
+
const tplPath = join(TEMPLATES_ROOT, 'instruction', instructionFileName);
|
|
190
|
+
if (existsSync(tplPath))
|
|
191
|
+
copyTemplate(w, tplPath, join(targetDir, instructionFileName), vars);
|
|
192
|
+
}
|
|
193
|
+
// --- Empty dirs + .gitkeep ---
|
|
194
|
+
createEmptyDirs(w, targetDir, r);
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
if (err instanceof SafeWriteError && w.created > 0) {
|
|
198
|
+
throw new SafeWriteError(`${err.message} ${w.created} file(s) had already been created before this failure; ` +
|
|
199
|
+
'init is not transactional and does not roll them back.', { code: err.code, phase: err.phase, publication: err.publication, path: err.path, tmp: err.tmp, cause: err.cause });
|
|
200
|
+
}
|
|
201
|
+
throw err;
|
|
202
|
+
}
|
|
203
|
+
// Track dirs created
|
|
204
|
+
dirsCreated.push(r, `${r}/memory`, `${r}/context`, `${r}/protocols`, `${r}/skills`, `${r}/governance`, `${r}/learning`, `${r}/tests`, `${r}/adr`);
|
|
205
|
+
console.log(` ✓ ${w.templates} files generated`);
|
|
206
|
+
console.log(` ✓ ${dirsCreated.length + 11} directories created`);
|
|
207
|
+
return { filesCreated: w.templates, dirsCreated, warnings: w.warnings };
|
|
208
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ProjectConfig {
|
|
2
|
+
projectName: string;
|
|
3
|
+
language: 'typescript' | 'javascript' | 'python' | 'other';
|
|
4
|
+
packageManager: 'pnpm' | 'npm' | 'yarn' | 'other';
|
|
5
|
+
aiTool: 'claude' | 'cursor' | 'windsurf' | 'other';
|
|
6
|
+
finalizationProtocol: string;
|
|
7
|
+
protocols: string[];
|
|
8
|
+
monolithRoot: string;
|
|
9
|
+
}
|
|
10
|
+
export interface InitOptions {
|
|
11
|
+
targetDir: string;
|
|
12
|
+
yes?: boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/init/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3D,cAAc,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IAClD,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACnD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Managed blocks (DX-UPDATE-003): the one mechanism by which `monolith init`
|
|
3
|
+
* and `monolith update` put MONOLITH-owned text into a file the user also owns
|
|
4
|
+
* (CLAUDE.md, AGENTS.md, routing-map, skills index) or into a MONOLITH-owned
|
|
5
|
+
* file the user may extend (`AGENT.md`).
|
|
6
|
+
*
|
|
7
|
+
* <!-- monolith:begin <id> sha256=<16 hex of the body> -->
|
|
8
|
+
* ...body...
|
|
9
|
+
* <!-- monolith:end <id> -->
|
|
10
|
+
*
|
|
11
|
+
* The checksum is what makes a refresh safe without a stored template version:
|
|
12
|
+
* a block whose body still matches its own checksum was never edited, so it is
|
|
13
|
+
* ours to refresh; a block that does not match carries a user edit and is left
|
|
14
|
+
* alone (CONFLICT). Everything outside the markers is never read for meaning
|
|
15
|
+
* and never changed. Markers inside fenced code blocks are examples, not blocks.
|
|
16
|
+
* This is not a Markdown parser: it knows lines, fences and these markers.
|
|
17
|
+
*/
|
|
18
|
+
export declare const BLOCK_IDS: readonly ["bootstrap", "agent", "routing-idea", "index-idea"];
|
|
19
|
+
export type BlockId = (typeof BLOCK_IDS)[number];
|
|
20
|
+
/** `{{MANAGED_<ID>}}` placeholder name used by the init templates. */
|
|
21
|
+
export declare function placeholderFor(id: BlockId): string;
|
|
22
|
+
export declare function bodyHash(body: string): string;
|
|
23
|
+
/** The body of a block for a given instance root. */
|
|
24
|
+
export declare function blockBody(id: BlockId, monolithRoot: string): string;
|
|
25
|
+
/** The block as it is written to a file (markers + body), ending in a newline. */
|
|
26
|
+
export declare function renderBlock(id: BlockId, body: string, eol?: string): string;
|
|
27
|
+
export type BlockState = {
|
|
28
|
+
state: 'absent';
|
|
29
|
+
}
|
|
30
|
+
/** Exactly one well-formed block whose body matches its checksum. `current`: also equals the template. */
|
|
31
|
+
| {
|
|
32
|
+
state: 'pristine';
|
|
33
|
+
current: boolean;
|
|
34
|
+
from: number;
|
|
35
|
+
to: number;
|
|
36
|
+
lines: string[];
|
|
37
|
+
} | {
|
|
38
|
+
state: 'edited';
|
|
39
|
+
detail: string;
|
|
40
|
+
} | {
|
|
41
|
+
state: 'malformed';
|
|
42
|
+
detail: string;
|
|
43
|
+
};
|
|
44
|
+
/** Classify `id` in `text` against the template body `desired`. */
|
|
45
|
+
export declare function inspectBlock(text: string, id: BlockId, desired: string): BlockState;
|
|
46
|
+
/** `text` plus the block, appended; every existing byte stays in place. */
|
|
47
|
+
export declare function appendBlock(text: string, id: BlockId, body: string): string;
|
|
48
|
+
/** `text` with only the lines of the block replaced. */
|
|
49
|
+
export declare function refreshBlock(text: string, state: Extract<BlockState, {
|
|
50
|
+
state: 'pristine';
|
|
51
|
+
}>, id: BlockId, body: string): string;
|
|
52
|
+
export type Planned = {
|
|
53
|
+
ok: true;
|
|
54
|
+
content: string;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
detail: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* `text` with the block appended, or the reason that is not safe. Safe means the
|
|
61
|
+
* result, read back by `inspectBlock`, shows exactly one well-formed, unedited
|
|
62
|
+
* block that equals the template, and every original byte is still in place.
|
|
63
|
+
* An unclosed code fence or HTML comment in `text` swallows the new markers (the next run would
|
|
64
|
+
* not see the block and append another), so it is refused up front.
|
|
65
|
+
*/
|
|
66
|
+
export declare function planAppend(text: string, id: BlockId, body: string): Planned;
|
|
67
|
+
/** `text` with the block refreshed in place, or the reason that is not safe (see `planAppend`). */
|
|
68
|
+
export declare function planRefresh(text: string, state: Extract<BlockState, {
|
|
69
|
+
state: 'pristine';
|
|
70
|
+
}>, id: BlockId, body: string): Planned;
|
|
71
|
+
/** Text with fenced code blocks and HTML comments removed: what an assistant reads as instructions. */
|
|
72
|
+
export declare function prose(text: string): string;
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/managed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH,eAAO,MAAM,SAAS,+DAAgE,CAAC;AACvF,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAMD,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAO,GAAG,MAAM,CAGzE;AA8FD,MAAM,MAAM,UAAU,GAClB;IAAE,KAAK,EAAE,QAAQ,CAAA;CAAE;AACrB,0GAA0G;GACxG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,GAClF;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAyBnF;AAMD,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI3E;AAED,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/H;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAW3E;AAED,mGAAmG;AACnG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM/H;AAQD,uGAAuG;AACvG,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1C"}
|