@hiroshi.inoue/agent-spectrum-kernel 1.0.0 → 1.1.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.ja.md +160 -0
- package/README.md +11 -154
- package/dist/AGENTS.md +1 -1
- package/dist/CUSTOM_INSTRUCTIONS.md +3 -2
- package/dist/README.md +11 -154
- package/dist/adapters/claude-code/plugin/skills/handoff/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/implement/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/investigate/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/review-pr/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/verify/SKILL.md +1 -1
- package/dist/docs/README.md +1 -0
- package/dist/docs/architecture/README.md +54 -0
- package/dist/docs/architecture/model.json +318 -0
- package/dist/docs/architecture/views/skill-assets.md +109 -0
- package/dist/docs/fixtures/adapter-runtime-bundle.json +85 -69
- package/dist/docs/fixtures/adapter-runtime-evidence.json +4 -4
- package/dist/docs/fixtures/adapter-runtime-profiles.json +97 -61
- package/dist/docs/fixtures/verification-proof-policy-cases.json +1 -1
- package/dist/docs/npm-distribution-ja.md +8 -6
- package/dist/docs/npm-distribution.md +6 -7
- package/dist/docs/routing-model.md +15 -0
- package/dist/docs/skill-matrix.md +4 -0
- package/dist/docs/validation-report.md +36 -30
- package/dist/manifest.json +36 -1
- package/dist/npm-runtime-inventory.json +214 -119
- package/dist/package.json +2 -2
- package/dist/schemas/adoption-plan.schema.json +5 -1
- package/dist/schemas/architecture-model.schema.json +619 -0
- package/dist/scripts/ask-primary-runtime-lineage.mjs +2 -1
- package/dist/scripts/ask-setup-apply-state.mjs +2 -2
- package/dist/scripts/ask-setup-apply.mjs +3 -3
- package/dist/scripts/ask-setup.mjs +37 -18
- package/dist/scripts/codex-exec-runner.mjs +7 -2
- package/dist/scripts/install-claude-adapter.mjs +14 -1
- package/dist/scripts/install-codex-adapter.mjs +17 -1
- package/dist/scripts/install-kernel.mjs +8 -4
- package/dist/scripts/installer-lifecycle.mjs +41 -0
- package/dist/scripts/kernel-principles.mjs +4 -2
- package/dist/skills/adr-review/SKILL.md +1 -0
- package/dist/skills/application-boundary-architecture/SKILL.md +1 -0
- package/dist/skills/architecture-decision-memory/SKILL.md +1 -0
- package/dist/skills/architecture-modeling/SKILL.md +22 -0
- package/dist/skills/architecture-modeling/references/architecture-model.mjs +441 -0
- package/dist/skills/architecture-modeling/references/last-seat.json +37 -0
- package/dist/skills/architecture-modeling/references/model.md +42 -0
- package/dist/skills/architecture-modeling/references/views.md +18 -0
- package/dist/skills/architecture-modeling/references/views.mjs +370 -0
- package/dist/skills/code-visualization/SKILL.md +8 -4
- package/dist/skills/code-visualization/references/design-preview.mjs +74 -0
- package/dist/skills/code-visualization/references/examples/last-seat.json +42 -0
- package/dist/skills/code-visualization/references/guide-input.md +30 -0
- package/dist/skills/code-visualization/references/render-guide.mjs +53 -11
- package/dist/skills/code-visualization/references/structure-index.mjs +41 -0
- package/dist/skills/code-visualization/references/visual-player.js +34 -3
- package/dist/skills/code-visualization/references/visual-surface.css +3 -0
- package/dist/skills/controlled-implementation/SKILL.md +4 -0
- package/dist/skills/documentation-knowledge-compiler/SKILL.md +2 -1
- package/dist/skills/doubt-driven-development/SKILL.md +2 -0
- package/dist/skills/engineering-documentation-generation/SKILL.md +27 -0
- package/dist/skills/engineering-documentation-generation/references/diagram-selection.md +25 -0
- package/dist/skills/engineering-documentation-generation/references/document-types.md +16 -0
- package/dist/skills/engineering-documentation-generation/references/reservation.md +61 -0
- package/dist/skills/engineering-documentation-generation/references/update-and-check.md +24 -0
- package/dist/skills/grill-design/SKILL.md +6 -2
- package/dist/skills/grill-with-docs/SKILL.md +4 -2
- package/dist/skills/handoff-generation/SKILL.md +1 -0
- package/dist/skills/implementation-context-generation/SKILL.md +1 -0
- package/dist/skills/mr-readme-generation/SKILL.md +2 -0
- package/dist/skills/operating-mode-router/SKILL.md +1 -0
- package/dist/skills/project-adoption-pack-generation/SKILL.md +1 -0
- package/dist/skills/refactor-implementation/SKILL.md +1 -0
- package/dist/skills/repository-orientation/SKILL.md +2 -0
- package/dist/skills/requirement-grill/SKILL.md +2 -0
- package/dist/skills/review-architecture-impact/SKILL.md +2 -0
- package/dist/skills/review-context-generation/SKILL.md +1 -0
- package/dist/skills/review-domain-impact/SKILL.md +2 -0
- package/dist/skills/skill-router/SKILL.md +5 -1
- package/dist/skills/spec-driven-development/SKILL.md +4 -0
- package/dist/skills/spec-driven-development/references/examples/javascript/candidate-preview.mjs +44 -0
- package/dist/skills/spec-driven-development/references/examples/javascript/scenario-review.mjs +10 -1
- package/dist/skills/spec-driven-development/references/scenario-visual-review.md +16 -0
- package/dist/skills/spec-driven-development/references/spec-index.md +8 -0
- package/dist/skills/test-first-verification/SKILL.md +2 -0
- package/dist/skills/work-package-compiler/SKILL.md +2 -0
- package/package.json +2 -2
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
overlayStagingResult,
|
|
44
44
|
readApplyJson,
|
|
45
45
|
resultBinding,
|
|
46
|
+
SETUP_INSTALLERS,
|
|
46
47
|
setupChildEnvironment,
|
|
47
48
|
setupInstallerInvocations,
|
|
48
49
|
} from "./ask-setup-apply-state.mjs";
|
|
@@ -119,31 +120,51 @@ export function snapshotTarget(target, { extraPaths = [] } = {}) {
|
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
export async function planningSource(adapter, profile) {
|
|
123
|
+
export async function planningSource(adapter, profile, target = null, retainCurrent = false) {
|
|
123
124
|
if (!ADAPTERS.includes(adapter)) throw new Error(`Unknown adapter: ${adapter}`);
|
|
125
|
+
const installer = SETUP_INSTALLERS[adapter === "kernel-only" ? "kernel" : adapter];
|
|
126
|
+
function installedState(entry) {
|
|
127
|
+
if (!target) return null;
|
|
128
|
+
validateSetupPaths(target, [entry.state]);
|
|
129
|
+
const path = resolve(target, entry.state);
|
|
130
|
+
return safeLstat(path) ? readApplyJson(path) : null;
|
|
131
|
+
}
|
|
132
|
+
const state = installedState(installer);
|
|
133
|
+
if (retainCurrent && (state?.installer !== installer.installer || state.install_status !== "installed" || !Array.isArray(state.selected_skills))) {
|
|
134
|
+
throw new Error("Cannot refresh an inactive or unknown Skill selection.");
|
|
135
|
+
}
|
|
124
136
|
let projection = null;
|
|
125
137
|
let selectedSkills;
|
|
126
138
|
if (adapter === "kernel-only") {
|
|
127
139
|
if (profile !== "kernel-only") throw new Error(`Unknown kernel-only profile: ${profile}`);
|
|
128
|
-
selectedSkills = [...readJson(resolve(REPO_ROOT, "manifest.json")).skills].sort();
|
|
140
|
+
selectedSkills = [...(retainCurrent ? state.selected_skills : readJson(resolve(REPO_ROOT, "manifest.json")).skills)].sort();
|
|
129
141
|
} else {
|
|
130
142
|
const build = await projectionBuilder(adapter);
|
|
131
|
-
projection = build(profile);
|
|
143
|
+
projection = build(profile, state, retainCurrent);
|
|
132
144
|
if (!projection.renderer_inputs?.canonical || !projection.renderer_inputs?.adapter_owned) {
|
|
133
145
|
throw new Error("Adapter projection is missing its authoritative renderer inputs.");
|
|
134
146
|
}
|
|
135
|
-
selectedSkills = projection.
|
|
147
|
+
selectedSkills = projection.selectedSkills ?? projection.skills;
|
|
136
148
|
}
|
|
137
149
|
if (!Array.isArray(selectedSkills) || selectedSkills.length === 0) throw new Error("Setup requires a non-empty resolved Skill selection.");
|
|
150
|
+
// An adapter refresh must not silently replace the kernel's separate selection.
|
|
151
|
+
let kernelSkills = selectedSkills;
|
|
152
|
+
if (retainCurrent && adapter !== "kernel-only") {
|
|
153
|
+
const core = installedState(SETUP_INSTALLERS.kernel);
|
|
154
|
+
if (core?.installer !== SETUP_INSTALLERS.kernel.installer || core.install_status !== "installed" ||
|
|
155
|
+
!Array.isArray(core.selected_skills) || !core.selected_skills.length)
|
|
156
|
+
throw new Error("Cannot refresh an unknown kernel selection. Choose a profile explicitly.");
|
|
157
|
+
kernelSkills = core.selected_skills;
|
|
158
|
+
}
|
|
138
159
|
validateSetupGitMetadata(REPO_ROOT);
|
|
139
160
|
const source = buildSetupSourceIdentity(REPO_ROOT, {
|
|
140
|
-
selectedSkills,
|
|
161
|
+
selectedSkills: [...kernelSkills, ...selectedSkills],
|
|
141
162
|
coreAssets: CORE_OWNED_IMMUTABLE_ASSETS,
|
|
142
163
|
rendererInputs: projection?.renderer_inputs ?? {},
|
|
143
164
|
projection,
|
|
144
165
|
revision: readSourceRevision(REPO_ROOT),
|
|
145
166
|
});
|
|
146
|
-
return { source, selectedSkills, projection };
|
|
167
|
+
return { source, selectedSkills, kernelSkills, projection };
|
|
147
168
|
}
|
|
148
169
|
|
|
149
170
|
function gitFacts(target) {
|
|
@@ -197,11 +218,11 @@ async function projectionBuilder(adapter) {
|
|
|
197
218
|
validateSetupGitMetadata(REPO_ROOT);
|
|
198
219
|
if (adapter === "codex") {
|
|
199
220
|
const module = await import("./install-codex-adapter.mjs");
|
|
200
|
-
return
|
|
221
|
+
return module.setupProjection;
|
|
201
222
|
}
|
|
202
223
|
if (adapter === "claude-code") {
|
|
203
224
|
const module = await import("./install-claude-adapter.mjs");
|
|
204
|
-
return
|
|
225
|
+
return module.setupProjection;
|
|
205
226
|
}
|
|
206
227
|
return null;
|
|
207
228
|
}
|
|
@@ -394,10 +415,6 @@ function diffSnapshots(before, after, ownership) {
|
|
|
394
415
|
});
|
|
395
416
|
}
|
|
396
417
|
|
|
397
|
-
function projectionSelection(adapter, profile) {
|
|
398
|
-
return { adapter, profile };
|
|
399
|
-
}
|
|
400
|
-
|
|
401
418
|
function portfolioReference(path) {
|
|
402
419
|
if (!path) return { status: "unselected", identity: null };
|
|
403
420
|
const value = readJson(resolve(path));
|
|
@@ -436,7 +453,9 @@ export async function createAdoptionPlan({ target, adapter, profile, purpose = n
|
|
|
436
453
|
if (!recommendation.profile) throw new Error(`Plan requires resolved profile. Outstanding decisions: ${recommendation.human_decisions.map((entry) => entry.id).join(", ")}`);
|
|
437
454
|
if (recommendation.human_decisions.some((entry) => entry.id.startsWith("capability:"))) throw new Error(`Required capability is unsupported or unknown: ${recommendation.human_decisions.filter((entry) => entry.id.startsWith("capability:")).map((entry) => entry.id.slice("capability:".length)).join(", ")}`);
|
|
438
455
|
|
|
439
|
-
const
|
|
456
|
+
const installed = beforeInspection.ask[adapter === "kernel-only" ? "core" : adapter === "codex" ? "codex" : "claude"];
|
|
457
|
+
const retainCurrent = !profile && !purpose && installed.install_status === "installed";
|
|
458
|
+
const { source, selectedSkills, kernelSkills, projection } = await planningSource(adapter, recommendation.profile, root, retainCurrent);
|
|
440
459
|
const projectedTargetPaths = (projection?.projectedManagedAssets ?? [])
|
|
441
460
|
.map((asset) => asset.path);
|
|
442
461
|
const planningPaths = [...new Set([
|
|
@@ -444,7 +463,7 @@ export async function createAdoptionPlan({ target, adapter, profile, purpose = n
|
|
|
444
463
|
...MANAGED_STATE_PATHS,
|
|
445
464
|
...managedPathsFromState(root),
|
|
446
465
|
...CORE_OWNED_IMMUTABLE_ASSETS,
|
|
447
|
-
...skillAssets(REPO_ROOT,
|
|
466
|
+
...skillAssets(REPO_ROOT, kernelSkills).map((asset) => asset.sourcePath),
|
|
448
467
|
...projectedTargetPaths,
|
|
449
468
|
])].sort();
|
|
450
469
|
assertSetupWritePaths(root, planningPaths);
|
|
@@ -461,7 +480,7 @@ export async function createAdoptionPlan({ target, adapter, profile, purpose = n
|
|
|
461
480
|
const phaseEvidence = [];
|
|
462
481
|
const applyPhases = [];
|
|
463
482
|
const beforeStaging = captureApplyTree(staging);
|
|
464
|
-
for (const invocation of setupInstallerInvocations(adapter, recommendation.profile,
|
|
483
|
+
for (const invocation of setupInstallerInvocations(adapter, recommendation.profile, kernelSkills, staging, retainCurrent)) {
|
|
465
484
|
assertSetupWritePaths(staging, planningPaths);
|
|
466
485
|
const dryRun = runNode(invocation.script, [...invocation.args, "--dry-run"]);
|
|
467
486
|
const result = runNode(invocation.script, invocation.args);
|
|
@@ -486,7 +505,7 @@ export async function createAdoptionPlan({ target, adapter, profile, purpose = n
|
|
|
486
505
|
const afterTargetSnapshot = snapshotTarget(root, { extraPaths: planningPaths });
|
|
487
506
|
if (planTargetSnapshot.digest !== afterTargetSnapshot.digest) throw new Error("Target changed while setup inspection/plan was running; retry from a fresh inspection.");
|
|
488
507
|
applyAssert(captureApplyTarget(root).binding.digest === applyBefore.binding.digest, "target_changed_during_planning");
|
|
489
|
-
const afterSource = await planningSource(adapter, recommendation.profile);
|
|
508
|
+
const afterSource = await planningSource(adapter, recommendation.profile, root, retainCurrent);
|
|
490
509
|
if (source.identity_digest !== afterSource.source.identity_digest) throw new Error("ASK setup source changed while planning; generate a fresh plan.");
|
|
491
510
|
|
|
492
511
|
const assetRefs = projection
|
|
@@ -502,7 +521,7 @@ export async function createAdoptionPlan({ target, adapter, profile, purpose = n
|
|
|
502
521
|
snapshot_digest: planTargetSnapshot.digest,
|
|
503
522
|
snapshot_paths: planTargetSnapshot.roots,
|
|
504
523
|
},
|
|
505
|
-
selection:
|
|
524
|
+
selection: { adapter, profile: recommendation.profile, ...(retainCurrent ? { retain_current: true } : {}) },
|
|
506
525
|
recommendation,
|
|
507
526
|
assets: { status: assetRefs.length > 0 ? "confirmed_from_projection" : "none_confirmed", exact_refs: assetRefs },
|
|
508
527
|
portfolio: portfolioReference(portfolioPath),
|
|
@@ -563,7 +582,7 @@ export async function verifyPlanIdentity(plan, { target, adapter = null } = {})
|
|
|
563
582
|
if (plan.environment?.target_realpath !== root
|
|
564
583
|
|| plan.application?.repository_locator_digest !== jsonDigest({ target_realpath: root })) throw new Error("Plan target repository path does not match the requested repository.");
|
|
565
584
|
if (adapter && plan.selection?.adapter !== adapter) throw new Error(`Plan adapter mismatch: planned=${plan.selection?.adapter} requested=${adapter}`);
|
|
566
|
-
const { source: currentSource } = await planningSource(plan.selection?.adapter, plan.selection?.profile);
|
|
585
|
+
const { source: currentSource } = await planningSource(plan.selection?.adapter, plan.selection?.profile, root, plan.selection?.retain_current);
|
|
567
586
|
if (canonicalJson(plan.source) !== canonicalJson(currentSource)) throw new Error("ASK setup source changed after the plan was generated.");
|
|
568
587
|
return { root, currentSource };
|
|
569
588
|
}
|
|
@@ -40,7 +40,7 @@ const MANAGED_CODEX_RUNTIME_FILES = [
|
|
|
40
40
|
function hashText(value) { return createHash("sha256").update(value).digest("hex"); }
|
|
41
41
|
|
|
42
42
|
/** One explicit session request; configuration/authentication remain owned by Codex. */
|
|
43
|
-
export async function executeCodexSession({ executable, argv, cwd, input, timeoutMs, signal, onSpawn, onOutput, onStdinReady, retainOutput = true, env, terminationScope = "process_group" }, spawnProcess = spawn,
|
|
43
|
+
export async function executeCodexSession({ executable, argv, cwd, input, timeoutMs, signal, onSpawn, onOutput, onStdinReady, syntheticFullInput = false, retainOutput = true, env, terminationScope = "process_group" }, spawnProcess = spawn,
|
|
44
44
|
{ now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout, platform = process.platform, signalProcess = process.kill } = {}) {
|
|
45
45
|
if (typeof executable !== "string" || !executable || executable.includes("\0")
|
|
46
46
|
|| !Array.isArray(argv) || argv.some(value => typeof value !== "string" || value.includes("\0"))
|
|
@@ -50,6 +50,8 @@ export async function executeCodexSession({ executable, argv, cwd, input, timeou
|
|
|
50
50
|
|| !Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647
|
|
51
51
|
|| (signal !== undefined && (!signal || typeof signal.aborted !== "boolean" || typeof signal.addEventListener !== "function" || typeof signal.removeEventListener !== "function"))
|
|
52
52
|
|| !["process_group", "direct_child"].includes(terminationScope)
|
|
53
|
+
|| typeof syntheticFullInput !== "boolean"
|
|
54
|
+
|| (syntheticFullInput && (spawnProcess === spawn || terminationScope !== "direct_child" || !onStdinReady || retainOutput))
|
|
53
55
|
|| (onSpawn !== undefined && typeof onSpawn !== "function") || (onOutput !== undefined && typeof onOutput !== "function")
|
|
54
56
|
|| (onStdinReady !== undefined && (typeof onStdinReady !== "function" || Buffer.byteLength(input) !== 0)) || typeof retainOutput !== "boolean" || typeof spawnProcess !== "function") {
|
|
55
57
|
throw new Error("a bounded Codex session request requires executable, argv, cwd, input and timeoutMs");
|
|
@@ -110,6 +112,9 @@ export async function executeCodexSession({ executable, argv, cwd, input, timeou
|
|
|
110
112
|
};
|
|
111
113
|
// Optional programmatic protocol input; ordinary sessions still end their
|
|
112
114
|
// fixed stdin once. The channel expires with this owned child's lifetime.
|
|
115
|
+
// The synthetic Full replay includes the complete pinned asset inventory.
|
|
116
|
+
// Catalog probes and ordinary protocol callers retain the 64 KiB limit.
|
|
117
|
+
const protocolInputLimit = syntheticFullInput ? 128 * 1024 : 64 * 1024;
|
|
113
118
|
let protocolInputBytes = 0, protocolInputClosed = false;
|
|
114
119
|
const startInput = () => {
|
|
115
120
|
if (!onStdinReady) {
|
|
@@ -122,7 +127,7 @@ export async function executeCodexSession({ executable, argv, cwd, input, timeou
|
|
|
122
127
|
const observed = onStdinReady(Object.freeze({
|
|
123
128
|
write(value) {
|
|
124
129
|
writable();
|
|
125
|
-
if (!(typeof value === "string" || Buffer.isBuffer(value)) || protocolInputBytes + Buffer.byteLength(value) >
|
|
130
|
+
if (!(typeof value === "string" || Buffer.isBuffer(value)) || protocolInputBytes + Buffer.byteLength(value) > protocolInputLimit) throw new Error("session protocol input exceeded its bound");
|
|
126
131
|
protocolInputBytes += Buffer.byteLength(value); return child.stdin.write(value);
|
|
127
132
|
},
|
|
128
133
|
end() { writable(); protocolInputClosed = true; child.stdin.end(); },
|
|
@@ -24,6 +24,7 @@ const DEFAULT_SKILLS = [
|
|
|
24
24
|
"angular-implementation-architecture",
|
|
25
25
|
"application-boundary-architecture",
|
|
26
26
|
"architecture-decision-memory",
|
|
27
|
+
"architecture-modeling",
|
|
27
28
|
"code-visualization",
|
|
28
29
|
"controlled-implementation",
|
|
29
30
|
"documentation-knowledge-compiler",
|
|
@@ -31,6 +32,7 @@ const DEFAULT_SKILLS = [
|
|
|
31
32
|
"doubt-driven-development",
|
|
32
33
|
"evidence-ledger",
|
|
33
34
|
"engineering-capability-evaluation",
|
|
35
|
+
"engineering-documentation-generation",
|
|
34
36
|
"engineering-pattern-ledger",
|
|
35
37
|
"grill-design",
|
|
36
38
|
"grill-with-docs",
|
|
@@ -398,6 +400,7 @@ function parseArgs(argv) {
|
|
|
398
400
|
args.target = resolve(argv[++i]);
|
|
399
401
|
} else if (arg === "--profile") {
|
|
400
402
|
args.profile = argv[++i];
|
|
403
|
+
args.explicitProfile = true;
|
|
401
404
|
} else if (arg === "--dry-run") {
|
|
402
405
|
args.dryRun = true;
|
|
403
406
|
} else if (arg === "--skip-hooks") {
|
|
@@ -432,7 +435,7 @@ function printHelp() {
|
|
|
432
435
|
|
|
433
436
|
Options:
|
|
434
437
|
--target <path> Adopting project root. Defaults to cwd.
|
|
435
|
-
--profile <name> Supported profile: daily, organizational, implementation, investigation, review, observability, full.
|
|
438
|
+
--profile <name> Supported profile: daily, organizational, implementation, investigation, review, observability, full. First install defaults to ${DEFAULT_PROFILE}. Updates retain the previous selection unless --profile or --skills is given.
|
|
436
439
|
--skills <csv> Advanced skill override. Installed commands must remain closed over required skills and assets.
|
|
437
440
|
--skip-hooks Do not copy hook config.
|
|
438
441
|
--skip-runtime Do not copy local runtime scripts or config.
|
|
@@ -982,6 +985,7 @@ function resolveSelection(args) {
|
|
|
982
985
|
args.requiredAssets = requiredAssets;
|
|
983
986
|
args.initialProjectStateAssets = initialProjectStateAssets;
|
|
984
987
|
args.runtimeDirectories = runtimeDirectories;
|
|
988
|
+
routingFixtures.push(...lifecycle.optionalDeliveryRoutes(manifest, selectedSkills, routingFixtures));
|
|
985
989
|
args.routingFixtures = routingFixtures;
|
|
986
990
|
args.requiredSkills = requiredSkills;
|
|
987
991
|
args.routerReachableSkills = skillsForRoutingFixtures(routingFixtures);
|
|
@@ -1043,6 +1047,14 @@ function claudeAssetKindForRecord(path, record) {
|
|
|
1043
1047
|
return "configuration";
|
|
1044
1048
|
}
|
|
1045
1049
|
|
|
1050
|
+
// Mirror CLI selection without including the target's stale inventory in source identity.
|
|
1051
|
+
export function setupProjection(profileName, state, retainCurrent = false) {
|
|
1052
|
+
const args = { profile: profileName, explicitProfile: !retainCurrent, skills: null };
|
|
1053
|
+
lifecycle.retainAdapterSelection(args, state, CLAUDE_PROFILES, readManifest());
|
|
1054
|
+
if (args.profile !== profileName) throw new Error("Installed profile changed during setup.");
|
|
1055
|
+
return buildClaudeProjectionPlan({ ...args, profileName });
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1046
1058
|
export function buildClaudeProjectionPlan({ profileName, skills = null, skipHooks = false, skipRuntime = false, skipCommands = false, previousState = null, prune = false } = {}) {
|
|
1047
1059
|
const args = { profile: profileName, skills, skipCommands };
|
|
1048
1060
|
resolveSelection(args);
|
|
@@ -1375,6 +1387,7 @@ function runMain(args) {
|
|
|
1375
1387
|
|
|
1376
1388
|
const manifest = readManifest();
|
|
1377
1389
|
args.previousState = readPreviousState(args.target);
|
|
1390
|
+
lifecycle.retainAdapterSelection(args, args.previousState, CLAUDE_PROFILES, manifest);
|
|
1378
1391
|
args.operations = [];
|
|
1379
1392
|
args.managedFiles = {};
|
|
1380
1393
|
args.managedPartialFiles = {};
|
|
@@ -362,6 +362,7 @@ function parseArgs(argv) {
|
|
|
362
362
|
args.target = resolve(argv[++i]);
|
|
363
363
|
} else if (arg === "--profile") {
|
|
364
364
|
args.profile = argv[++i];
|
|
365
|
+
args.explicitProfile = true;
|
|
365
366
|
} else if (arg === "--skills") {
|
|
366
367
|
args.skills = argv[++i].split(",").map((skill) => skill.trim()).filter(Boolean);
|
|
367
368
|
} else if (arg === "--merge-agents" || arg === "--skip-agents") {
|
|
@@ -404,7 +405,7 @@ function printHelp() {
|
|
|
404
405
|
|
|
405
406
|
Options:
|
|
406
407
|
--target <path> Adopting project root. Defaults to cwd.
|
|
407
|
-
--profile <name> Workflow profile.
|
|
408
|
+
--profile <name> Workflow profile. First install defaults to ${DEFAULT_PROFILE}. Updates retain the previous selection unless --profile or --skills is given.
|
|
408
409
|
--skills <csv> Advanced override for projected skills. Must satisfy selected prompt, command, router reachability, and skill dependency closure.
|
|
409
410
|
--skip-prompts Do not copy Codex prompt templates into .agents/prompts.
|
|
410
411
|
--skip-command Do not copy the codex exec command template into .agents/commands.
|
|
@@ -829,6 +830,12 @@ function resolveCodexProjectionSelection({ profileName, skills = null, skipPromp
|
|
|
829
830
|
const selectedSkills = [...(skills ?? requiredSkills)].sort();
|
|
830
831
|
validateSkillNames(selectedSkills, [...manifest.skills].sort());
|
|
831
832
|
validateSkillClosure({ selectedSkills, requiredSkills, profileName });
|
|
833
|
+
for (const fixture of lifecycle.optionalDeliveryRoutes(manifest, selectedSkills, routingFixtures)) {
|
|
834
|
+
routingFixtures.push({
|
|
835
|
+
id: fixture.id, signal: fixture.signal, router: fixture.router, selected_route: fixture.selectedRoute,
|
|
836
|
+
outcome: fixture.outcome, recommended_profile: fixture.recommendedProfile, required_skills: fixture.requiredSkills,
|
|
837
|
+
});
|
|
838
|
+
}
|
|
832
839
|
const requiredAssets = [...new Set([
|
|
833
840
|
"scripts/json-schema-validation.mjs",
|
|
834
841
|
"schemas/execution-envelope.schema.json",
|
|
@@ -891,6 +898,14 @@ function codexAssetKindForRecord(path, record) {
|
|
|
891
898
|
return "configuration";
|
|
892
899
|
}
|
|
893
900
|
|
|
901
|
+
// Mirror CLI selection without including the target's stale inventory in source identity.
|
|
902
|
+
export function setupProjection(profileName, state, retainCurrent = false) {
|
|
903
|
+
const args = { profile: profileName, explicitProfile: !retainCurrent, skills: null };
|
|
904
|
+
lifecycle.retainAdapterSelection(args, state, CODEX_PROFILES, readManifest());
|
|
905
|
+
if (args.profile !== profileName) throw new Error("Installed profile changed during setup.");
|
|
906
|
+
return buildCodexProjectionPlan({ ...args, profileName });
|
|
907
|
+
}
|
|
908
|
+
|
|
894
909
|
export function buildCodexProjectionPlan({ profileName, skills = null, skipPrompts = false, skipCommand = false, previousState = null, prune = false } = {}) {
|
|
895
910
|
const selection = resolveCodexProjectionSelection({ profileName, skills, skipPrompts, skipCommand });
|
|
896
911
|
const planShapingOptions = { skills: skills ? [...new Set(skills)].sort() : null, skip_prompts: skipPrompts, skip_command: skipCommand };
|
|
@@ -1152,6 +1167,7 @@ function validateManagedReferences(managedFiles) {
|
|
|
1152
1167
|
|
|
1153
1168
|
function buildPlan(args) {
|
|
1154
1169
|
const previousState = readPreviousState(args.target);
|
|
1170
|
+
lifecycle.retainAdapterSelection(args, previousState, CODEX_PROFILES, readManifest());
|
|
1155
1171
|
const projectionPlan = buildCodexProjectionPlan({
|
|
1156
1172
|
profileName: args.profile,
|
|
1157
1173
|
skills: args.skills,
|
|
@@ -87,7 +87,7 @@ function printHelp() {
|
|
|
87
87
|
|
|
88
88
|
Options:
|
|
89
89
|
--target <path> Adopting project root. Defaults to cwd.
|
|
90
|
-
--skills <csv>
|
|
90
|
+
--skills <csv> Core skills to project. Defaults to all on first install, then the previous selection.
|
|
91
91
|
--merge-agents Add or update the managed block in an existing AGENTS.md.
|
|
92
92
|
--skip-custom-instructions Do not project CUSTOM_INSTRUCTIONS.md.
|
|
93
93
|
--no-overwrite-skills Fail when an existing projected skill would be overwritten.
|
|
@@ -206,10 +206,12 @@ function previousManagedRecord(previousState, relativePath) {
|
|
|
206
206
|
function buildPlan(args) {
|
|
207
207
|
const manifest = readManifest();
|
|
208
208
|
const manifestSkills = [...manifest.skills].sort();
|
|
209
|
-
const
|
|
209
|
+
const previousState = readPreviousState(args.target);
|
|
210
|
+
const retained = previousState?.install_status === "installed" ? previousState.selected_skills : manifestSkills;
|
|
211
|
+
if (args.skills === null && !Array.isArray(retained)) throw new Error("Missing previous selection. Specify --skills explicitly.");
|
|
212
|
+
const skills = [...(args.skills ?? retained)].sort();
|
|
210
213
|
validateSkillNames(skills, manifestSkills);
|
|
211
214
|
|
|
212
|
-
const previousState = readPreviousState(args.target);
|
|
213
215
|
const previousSkillNames = (Array.isArray(previousState?.installed_skills) ? previousState.installed_skills : []).filter((skill) =>
|
|
214
216
|
typeof skill === "string" && SKILL_NAME_PATTERN.test(skill),
|
|
215
217
|
);
|
|
@@ -250,7 +252,9 @@ function buildPlan(args) {
|
|
|
250
252
|
rollback,
|
|
251
253
|
});
|
|
252
254
|
|
|
253
|
-
|
|
255
|
+
const previouslyOmitted = previousState?.install_status === "installed" &&
|
|
256
|
+
!Object.hasOwn(previousState.managed_files ?? {}, "CUSTOM_INSTRUCTIONS.md");
|
|
257
|
+
if (!args.skipCustomInstructions && !previouslyOmitted) {
|
|
254
258
|
const customSource = resolve(REPO_ROOT, "CUSTOM_INSTRUCTIONS.md");
|
|
255
259
|
ensureSource(customSource, "CUSTOM_INSTRUCTIONS.md");
|
|
256
260
|
const customContent = readText(customSource);
|
|
@@ -23,6 +23,7 @@ export const CORE_IMMUTABLE_CONTRACT_ASSETS = Object.freeze([
|
|
|
23
23
|
"docs/stack-implementation-overlay-contract.md",
|
|
24
24
|
"docs/verification-proof-policy-contract.md",
|
|
25
25
|
"schemas/adapter-runtime-event.schema.json",
|
|
26
|
+
"schemas/architecture-model.schema.json",
|
|
26
27
|
"schemas/claim-evidence-status.schema.json",
|
|
27
28
|
"schemas/claim-evidence-status.schema.json",
|
|
28
29
|
"schemas/compact-profile-control-map.json",
|
|
@@ -48,6 +49,46 @@ export const CORE_OWNED_IMMUTABLE_ASSETS = Object.freeze([
|
|
|
48
49
|
...CORE_IMMUTABLE_RUNTIME_ASSETS,
|
|
49
50
|
]);
|
|
50
51
|
|
|
52
|
+
// An unqualified update refreshes the active selection. Only a new installation
|
|
53
|
+
// or an explicit profile/override adopts the contents of a newly expanded pack.
|
|
54
|
+
export function retainAdapterSelection(args, state, profiles, manifest) {
|
|
55
|
+
if (state?.install_status !== "installed") return;
|
|
56
|
+
// Selecting another set of skills does not re-enable prompts, hooks or runtime.
|
|
57
|
+
const options = state.projection_plan?.plan_shaping_options;
|
|
58
|
+
if (options?.skip_hooks) args.skipHooks = true;
|
|
59
|
+
if (options?.skip_runtime) args.skipRuntime = true;
|
|
60
|
+
if (options?.skip_prompts) args.skipPrompts = true;
|
|
61
|
+
if (options?.skip_command) args.skipCommand = true;
|
|
62
|
+
if (args.explicitProfile || args.skills !== null) return;
|
|
63
|
+
const profile = Object.hasOwn(profiles, state.selected_profile) && profiles[state.selected_profile];
|
|
64
|
+
if (!profile || !Array.isArray(state.selected_skills)) {
|
|
65
|
+
throw new Error("Cannot determine the previous selection. Choose --profile or an explicit closed --skills list.");
|
|
66
|
+
}
|
|
67
|
+
args.profile = state.selected_profile;
|
|
68
|
+
const seed = profile.projectionPack ? manifest.projection_packs[profile.projectionPack].skills : profile.skills ?? manifest.skills;
|
|
69
|
+
if (state.selection_mode === "custom" || seed.some(skill => !state.selected_skills.includes(skill))) {
|
|
70
|
+
args.skills = state.selected_skills;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// These delivery routes are optional capabilities. Describe them after dependency
|
|
75
|
+
// closure so a route can never select itself in an older or custom installation.
|
|
76
|
+
export function optionalDeliveryRoutes(manifest, selectedSkills, fixtures) {
|
|
77
|
+
if (!selectedSkills.includes("skill-router")) return [];
|
|
78
|
+
const ids = ["architecture_model", "engineering_documentation", "code_and_design_visualization", "executable_spec_setup"];
|
|
79
|
+
return manifest.routing.default_routes
|
|
80
|
+
.filter(route => ids.includes(route.id) && !fixtures.some(fixture => fixture.id === route.id))
|
|
81
|
+
.map(({ id, primary, signals }) => {
|
|
82
|
+
const available = selectedSkills.includes(primary);
|
|
83
|
+
return {
|
|
84
|
+
id, signal: signals[0], router: "skill-router", selectedRoute: primary,
|
|
85
|
+
outcome: available ? "available" : "capability_missing",
|
|
86
|
+
recommendedProfile: available ? null : "daily",
|
|
87
|
+
requiredSkills: available ? [primary] : [],
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
51
92
|
export function coreImmutableAssetKind(asset) {
|
|
52
93
|
if (CORE_IMMUTABLE_CONTRACT_ASSETS.includes(asset)) return "immutable_contract";
|
|
53
94
|
if (CORE_IMMUTABLE_RUNTIME_ASSETS.includes(asset)) return "immutable_runtime";
|
|
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
|
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
|
|
5
5
|
export const KERNEL_PRINCIPLES_ID = "kernel_principles_v1";
|
|
6
|
-
export const KERNEL_PRINCIPLES_SOURCE_DIGEST = "sha256:
|
|
6
|
+
export const KERNEL_PRINCIPLES_SOURCE_DIGEST = "sha256:99f857623ed98f4315032bc2fdd248160a57d8c3dba2972e3c2dc79d63312f38";
|
|
7
7
|
// Retain the reviewed 5f36081 source for replay; new sources never inherit a seal.
|
|
8
8
|
const reviewedSourceRevisions = new Map([
|
|
9
9
|
["sha256:173b0ae1cbb3a92cb434b60c5d233dbd0e2b68b75be9732818d8b53cbb3b5d6c", 1],
|
|
@@ -15,7 +15,9 @@ const reviewedSourceRevisions = new Map([
|
|
|
15
15
|
// Extraction boundaries are unchanged; historical sources retain their own identities.
|
|
16
16
|
["sha256:b32619ee2ec91361577956476a84588904e021b14ef0d77b081a739535ab1481", 4],
|
|
17
17
|
// Reviewed independent expectations, bounded evidence reuse and simple-task proportionality.
|
|
18
|
-
[
|
|
18
|
+
["sha256:6e28a7f89a1fb1f2454014f3ef38b89c076de9a68e9ec63b340655bebf7ed9f3", 5],
|
|
19
|
+
// Section 2 adds source tracing for material decisions. Maps remain optional.
|
|
20
|
+
[KERNEL_PRINCIPLES_SOURCE_DIGEST, 6],
|
|
19
21
|
]);
|
|
20
22
|
const hash = value => `sha256:${createHash("sha256").update(value).digest("hex")}`;
|
|
21
23
|
|
|
@@ -40,6 +40,7 @@ Reversibility:
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
3. Check consistency with previous decisions.
|
|
43
|
+
- Where a model exists, trace affected element IDs to accepted rationale and actual implementation. Distinguish outdated views, code drift and a genuinely superseded choice. Propose a correction at the responsible source. A diagram alone cannot supersede an ADR.
|
|
43
44
|
|
|
44
45
|
4. Check whether architecture memory should be added, refreshed, contradicted, or promoted into ADR work.
|
|
45
46
|
|
|
@@ -34,6 +34,7 @@ Use these invariants as the compact first-pass decision model:
|
|
|
34
34
|
2. Classify the decision surface: feature boundary, dependency direction, state ownership, external I/O, async lifetime, usecase, repository/port/adapter, mapper, DTO/domain/view model, typed error, ID boundary, test boundary, or guardrail.
|
|
35
35
|
3. Classify the code maturity: new code, mature feature code, critical/security/boundary code, or legacy code.
|
|
36
36
|
4. Choose the smallest boundary that names a real policy or isolates a real source of change.
|
|
37
|
+
- For material alternatives, compare the same change across candidate runtime boundaries (C2) and internal responsibilities (C3). Identify the state owner, public contract, dependency direction, external I/O, async lifetime and trust boundary that would move. Check those against the kernel above. A class, folder or framework layer does not dictate a component. Coordinate system-wide choices with `grill-design` when selected.
|
|
37
38
|
5. Validate with repository scripts first: focused tests, typecheck/build, lint, then broader tests when shared behavior changed.
|
|
38
39
|
|
|
39
40
|
## Code Maturity Classification
|
|
@@ -32,6 +32,7 @@ This skill is the pre-ADR and cross-task memory layer. ADRs remain the canonical
|
|
|
32
32
|
- Dependency direction, module boundary, feature public API, persistence boundary, infrastructure boundary, DTO/error trust boundary, async lifetime, ownership, lifecycle, or coupling.
|
|
33
33
|
|
|
34
34
|
2. Gather decision evidence.
|
|
35
|
+
- If a model points here, link relevant element IDs and checked revisions to the existing rationale. Separate stale descriptions from a changed boundary or unresolved decision. Route corrections to the owning source without promoting proposals.
|
|
35
36
|
- Code structure, imports, tests, docs, ADRs, review findings, issue discussion, Work Package, or human confirmation.
|
|
36
37
|
- Options considered, accepted option, rejected alternatives, tradeoffs, consequences, and constraints.
|
|
37
38
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-modeling
|
|
3
|
+
description: Explain a system, map or refresh its architecture, compare proposed boundaries and trace responsibilities to specifications, code, and checks. システムの全体像や構成図、設計案の違いを根拠まで辿る。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Architecture modeling
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Start with the reader's question, target repository and revision (both sides for a change). Pick the smallest relevant scope. For a routine edit, follow a current link directly and inspect the actual code, contract and test. No model, report or additional gate is required.
|
|
11
|
+
|
|
12
|
+
## Process
|
|
13
|
+
|
|
14
|
+
1. Find the existing diagrams, accepted requirements and decisions. Identify the user and external systems (C1), then the applications and stores that execute or persist work (C2). Zoom into responsibilities (C3) only where the decision needs it. A library can be a partial view. Do not turn a directory, class or package into a runtime boundary by default.
|
|
15
|
+
2. Follow a representative input through the actual entry point, contract, owner, important alternative and consumer. Check the evidence behind every material assertion. Keep intended behavior, actual static implementation, proposed alternatives and observed executions separate. Explicitly identify missing proof or authority. Only explicit rules constrain dependencies.
|
|
16
|
+
3. Use the [model and CLI](references/model.md) for reusable structure, comparison or a freshness check. The local tool uses the core files `schemas/architecture-model.schema.json`, `schemas/claim-evidence-status.schema.json` and `scripts/json-schema-validation.mjs`. It checks references and bytes, never infers responsibility or approves a decision.
|
|
17
|
+
4. Lead with purpose, a representative outcome and ownership. Show the relevant levels, labeled directions, affected paths, gaps, decision owner and next check. [Reading and design guide](references/views.md). Return business choices to the requirement owner and boundary choices to the design owner. Preserve current Spec, ADR, code and execution records as separate authorities.
|
|
18
|
+
5. Recheck the selected scope. If absent, stale, conflicting or unsupported, fall back to direct exploration for affected claims. Continue independent work. Missing optional capabilities never authorize invoking an unselected skill. Route an explicit unavailable request through the existing capability check.
|
|
19
|
+
|
|
20
|
+
## Output
|
|
21
|
+
|
|
22
|
+
An explanation can stay in the answer. Only persist when requested or allowed by an adopted project's policy. Reuse its locations and terminology. Generate views separately from authored material. Never send sources to a service, store secrets, customer data or raw prompts, or promote the index into knowledge or change a source of truth merely to make the view agree.
|