@nimiplatform/nimi-coding 0.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/LICENSE +21 -0
- package/README.md +348 -0
- package/adapters/README.md +25 -0
- package/adapters/claude/README.md +89 -0
- package/adapters/claude/profile.yaml +70 -0
- package/adapters/codex/README.md +53 -0
- package/adapters/codex/profile.yaml +78 -0
- package/adapters/oh-my-codex/README.md +185 -0
- package/adapters/oh-my-codex/profile.yaml +46 -0
- package/bin/nimicoding.mjs +6 -0
- package/cli/commands/admit-high-risk-decision.mjs +108 -0
- package/cli/commands/audit-sweep.mjs +341 -0
- package/cli/commands/blueprint-audit.mjs +91 -0
- package/cli/commands/clear.mjs +168 -0
- package/cli/commands/closeout.mjs +183 -0
- package/cli/commands/decide-high-risk-execution.mjs +124 -0
- package/cli/commands/doctor.mjs +53 -0
- package/cli/commands/generate-spec-derived-docs.mjs +131 -0
- package/cli/commands/handoff.mjs +123 -0
- package/cli/commands/ingest-high-risk-execution.mjs +95 -0
- package/cli/commands/review-high-risk-execution.mjs +95 -0
- package/cli/commands/start.mjs +717 -0
- package/cli/commands/topic-formatters.mjs +382 -0
- package/cli/commands/topic-goal.mjs +33 -0
- package/cli/commands/topic-options-shared.mjs +27 -0
- package/cli/commands/topic-options-workflow.mjs +767 -0
- package/cli/commands/topic-options.mjs +626 -0
- package/cli/commands/topic-runner.mjs +169 -0
- package/cli/commands/topic.mjs +795 -0
- package/cli/commands/validate-acceptance.mjs +5 -0
- package/cli/commands/validate-ai-governance.mjs +214 -0
- package/cli/commands/validate-execution-packet.mjs +5 -0
- package/cli/commands/validate-orchestration-state.mjs +5 -0
- package/cli/commands/validate-prompt.mjs +5 -0
- package/cli/commands/validate-spec-audit.mjs +27 -0
- package/cli/commands/validate-spec-governance.mjs +124 -0
- package/cli/commands/validate-spec-tree.mjs +27 -0
- package/cli/commands/validate-worker-output.mjs +5 -0
- package/cli/constants.mjs +489 -0
- package/cli/help.mjs +134 -0
- package/cli/index.mjs +103 -0
- package/cli/lib/adapter-profiles.mjs +403 -0
- package/cli/lib/audit-execution.mjs +52 -0
- package/cli/lib/audit-sweep-runtime/admissions.mjs +381 -0
- package/cli/lib/audit-sweep-runtime/audit-validity.mjs +333 -0
- package/cli/lib/audit-sweep-runtime/chunks.mjs +697 -0
- package/cli/lib/audit-sweep-runtime/closeout.mjs +144 -0
- package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +639 -0
- package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +515 -0
- package/cli/lib/audit-sweep-runtime/common.mjs +329 -0
- package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +172 -0
- package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +152 -0
- package/cli/lib/audit-sweep-runtime/format.mjs +57 -0
- package/cli/lib/audit-sweep-runtime/ingest.mjs +486 -0
- package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +198 -0
- package/cli/lib/audit-sweep-runtime/inventory.mjs +728 -0
- package/cli/lib/audit-sweep-runtime/ledger.mjs +315 -0
- package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +101 -0
- package/cli/lib/audit-sweep-runtime/remediation.mjs +349 -0
- package/cli/lib/audit-sweep-runtime/rerun.mjs +129 -0
- package/cli/lib/audit-sweep-runtime/risk-budget.mjs +300 -0
- package/cli/lib/audit-sweep-runtime/status.mjs +62 -0
- package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +215 -0
- package/cli/lib/audit-sweep-runtime/validators.mjs +758 -0
- package/cli/lib/audit-sweep.mjs +18 -0
- package/cli/lib/authority-convergence.mjs +309 -0
- package/cli/lib/blueprint-audit.mjs +370 -0
- package/cli/lib/bootstrap.mjs +228 -0
- package/cli/lib/closeout.mjs +623 -0
- package/cli/lib/codex-sdk-runner.mjs +76 -0
- package/cli/lib/contracts.mjs +180 -0
- package/cli/lib/doctor.mjs +18 -0
- package/cli/lib/entrypoints.mjs +274 -0
- package/cli/lib/external-execution.mjs +101 -0
- package/cli/lib/fs-helpers.mjs +33 -0
- package/cli/lib/handoff.mjs +785 -0
- package/cli/lib/high-risk-admission.mjs +442 -0
- package/cli/lib/high-risk-decision.mjs +324 -0
- package/cli/lib/high-risk-ingest.mjs +317 -0
- package/cli/lib/high-risk-review.mjs +263 -0
- package/cli/lib/internal/contracts-loaders.mjs +132 -0
- package/cli/lib/internal/contracts-parse-high-risk.mjs +131 -0
- package/cli/lib/internal/contracts-parse.mjs +457 -0
- package/cli/lib/internal/contracts-validators.mjs +398 -0
- package/cli/lib/internal/doctor-bootstrap-surface.mjs +359 -0
- package/cli/lib/internal/doctor-delegated-surface.mjs +256 -0
- package/cli/lib/internal/doctor-finalize.mjs +385 -0
- package/cli/lib/internal/doctor-format.mjs +286 -0
- package/cli/lib/internal/doctor-inspectors.mjs +294 -0
- package/cli/lib/internal/doctor-state.mjs +205 -0
- package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +315 -0
- package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +358 -0
- package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +155 -0
- package/cli/lib/internal/governance/ai/check-high-risk-doc-metadata-core.mjs +173 -0
- package/cli/lib/internal/governance/config.mjs +150 -0
- package/cli/lib/internal/governance/runner.mjs +35 -0
- package/cli/lib/internal/governance/shared/read-yaml-with-fragments.mjs +49 -0
- package/cli/lib/internal/validators-artifacts.mjs +515 -0
- package/cli/lib/internal/validators-shared.mjs +28 -0
- package/cli/lib/internal/validators-spec-helpers.mjs +186 -0
- package/cli/lib/internal/validators-spec.mjs +410 -0
- package/cli/lib/shared.mjs +83 -0
- package/cli/lib/topic-draft-packets.mjs +48 -0
- package/cli/lib/topic-goal.mjs +361 -0
- package/cli/lib/topic-runner.mjs +772 -0
- package/cli/lib/topic.mjs +93 -0
- package/cli/lib/ui.mjs +178 -0
- package/cli/lib/validators.mjs +78 -0
- package/cli/lib/value-helpers.mjs +24 -0
- package/cli/lib/yaml-helpers.mjs +133 -0
- package/cli/nimicoding.mjs +1 -0
- package/cli/seeds/bootstrap.mjs +47 -0
- package/config/audit-execution-artifacts.yaml +20 -0
- package/config/bootstrap.yaml +6 -0
- package/config/external-execution-artifacts.yaml +16 -0
- package/config/host-adapter.yaml +30 -0
- package/config/host-profile.yaml +29 -0
- package/config/installer-evidence.yaml +31 -0
- package/config/skill-installer.yaml +23 -0
- package/config/skill-manifest.yaml +46 -0
- package/config/skills.yaml +30 -0
- package/config/spec-generation-inputs.yaml +25 -0
- package/contracts/acceptance.schema.yaml +16 -0
- package/contracts/admission-checklist.schema.yaml +15 -0
- package/contracts/audit-chunk.schema.yaml +110 -0
- package/contracts/audit-closeout.schema.yaml +51 -0
- package/contracts/audit-finding.schema.yaml +61 -0
- package/contracts/audit-ledger.schema.yaml +138 -0
- package/contracts/audit-plan.schema.yaml +123 -0
- package/contracts/audit-remediation-map.schema.yaml +51 -0
- package/contracts/audit-rerun.schema.yaml +31 -0
- package/contracts/audit-sweep-result.yaml +49 -0
- package/contracts/authority-convergence-audit.schema.yaml +19 -0
- package/contracts/closeout.schema.yaml +25 -0
- package/contracts/decision-review.schema.yaml +16 -0
- package/contracts/doc-spec-audit-result.yaml +19 -0
- package/contracts/execution-packet.schema.yaml +49 -0
- package/contracts/external-host-compatibility.yaml +22 -0
- package/contracts/forbidden-shortcuts.catalog.yaml +23 -0
- package/contracts/high-risk-admission.schema.yaml +23 -0
- package/contracts/high-risk-execution-result.yaml +20 -0
- package/contracts/orchestration-state.schema.yaml +41 -0
- package/contracts/overflow-continuation.schema.yaml +12 -0
- package/contracts/packet.schema.yaml +30 -0
- package/contracts/pending-note.schema.yaml +17 -0
- package/contracts/prompt.schema.yaml +12 -0
- package/contracts/remediation.schema.yaml +16 -0
- package/contracts/result.schema.yaml +24 -0
- package/contracts/spec-generation-audit.schema.yaml +31 -0
- package/contracts/spec-generation-inputs.schema.yaml +39 -0
- package/contracts/spec-reconstruction-result.yaml +37 -0
- package/contracts/topic-goal.schema.yaml +78 -0
- package/contracts/topic-run-ledger.schema.yaml +72 -0
- package/contracts/topic-step-decision.schema.yaml +45 -0
- package/contracts/topic.schema.yaml +65 -0
- package/contracts/true-close.schema.yaml +15 -0
- package/contracts/wave.schema.yaml +29 -0
- package/contracts/worker-output.schema.yaml +15 -0
- package/methodology/audit-sweep-p0p1-recall.yaml +45 -0
- package/methodology/authority-convergence-policy.yaml +42 -0
- package/methodology/core.yaml +25 -0
- package/methodology/four-closure-policy.yaml +28 -0
- package/methodology/overflow-continuation-policy.yaml +14 -0
- package/methodology/role-separation-policy.yaml +28 -0
- package/methodology/skill-exchange-projection.yaml +114 -0
- package/methodology/skill-handoff.yaml +34 -0
- package/methodology/skill-installer-result.yaml +27 -0
- package/methodology/skill-installer-summary-projection.yaml +181 -0
- package/methodology/skill-runtime.yaml +23 -0
- package/methodology/spec-reconstruction.yaml +63 -0
- package/methodology/spec-target-truth-profile.yaml +53 -0
- package/methodology/topic-lifecycle-report.yaml +144 -0
- package/methodology/topic-lifecycle.yaml +37 -0
- package/methodology/topic-naming-ontology.yaml +21 -0
- package/methodology/topic-ontology.yaml +38 -0
- package/methodology/topic-validation-policy.yaml +9 -0
- package/methodology/wave-dag-policy.yaml +14 -0
- package/package.json +50 -0
- package/spec/_meta/command-gating-matrix.yaml +110 -0
- package/spec/_meta/generate-drift-migration-checklist.yaml +155 -0
- package/spec/_meta/governance-routing-cutover-checklist.yaml +35 -0
- package/spec/_meta/phase2-impacted-surface-matrix.yaml +44 -0
- package/spec/_meta/spec-authority-cutover-readiness.yaml +104 -0
- package/spec/_meta/spec-tree-model.yaml +72 -0
- package/spec/bootstrap-state.yaml +99 -0
- package/spec/product-scope.yaml +56 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, rm, rmdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BOOTSTRAP_CONTRACT_ID,
|
|
6
|
+
BOOTSTRAP_CONTRACT_VERSION,
|
|
7
|
+
LOCAL_GITIGNORE_ENTRIES,
|
|
8
|
+
PACKAGE_NAME,
|
|
9
|
+
REQUIRED_LOCAL_DIRS,
|
|
10
|
+
} from "../constants.mjs";
|
|
11
|
+
import { createBootstrapSeedFileMap } from "../seeds/bootstrap.mjs";
|
|
12
|
+
import { appendGitignoreEntries, pathExists, readTextIfFile } from "./fs-helpers.mjs";
|
|
13
|
+
import { readYamlScalar } from "./yaml-helpers.mjs";
|
|
14
|
+
|
|
15
|
+
export async function previewBootstrapWrites(projectRoot) {
|
|
16
|
+
const missingFiles = [];
|
|
17
|
+
const missingDirs = [];
|
|
18
|
+
const seedMap = await createBootstrapSeedFileMap();
|
|
19
|
+
|
|
20
|
+
for (const relativeDir of REQUIRED_LOCAL_DIRS) {
|
|
21
|
+
const dirPath = path.join(projectRoot, relativeDir);
|
|
22
|
+
const info = await pathExists(dirPath);
|
|
23
|
+
if (!info || !info.isDirectory()) {
|
|
24
|
+
missingDirs.push(relativeDir);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
for (const relativePath of seedMap.keys()) {
|
|
29
|
+
const absolutePath = path.join(projectRoot, relativePath);
|
|
30
|
+
const info = await pathExists(absolutePath);
|
|
31
|
+
if (!info) {
|
|
32
|
+
missingFiles.push(relativePath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const gitignoreText = await readTextIfFile(path.join(projectRoot, ".gitignore"));
|
|
37
|
+
const missingGitignoreEntries = gitignoreText === null
|
|
38
|
+
? LOCAL_GITIGNORE_ENTRIES.slice()
|
|
39
|
+
: LOCAL_GITIGNORE_ENTRIES.filter((entry) => !gitignoreText.includes(entry));
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
missingFiles,
|
|
43
|
+
missingDirs,
|
|
44
|
+
missingGitignoreEntries,
|
|
45
|
+
hasWork: missingFiles.length > 0 || missingDirs.length > 0 || missingGitignoreEntries.length > 0,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function writeMissingBootstrapFiles(projectRoot) {
|
|
50
|
+
const createdFiles = [];
|
|
51
|
+
const createdDirs = [];
|
|
52
|
+
const seedMap = await createBootstrapSeedFileMap();
|
|
53
|
+
|
|
54
|
+
for (const relativeDir of REQUIRED_LOCAL_DIRS) {
|
|
55
|
+
const dirPath = path.join(projectRoot, relativeDir);
|
|
56
|
+
const info = await pathExists(dirPath);
|
|
57
|
+
if (!info) {
|
|
58
|
+
await mkdir(dirPath, { recursive: true });
|
|
59
|
+
createdDirs.push(relativeDir);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const [relativePath, content] of seedMap.entries()) {
|
|
64
|
+
const absolutePath = path.join(projectRoot, relativePath);
|
|
65
|
+
const info = await pathExists(absolutePath);
|
|
66
|
+
if (info) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await mkdir(path.dirname(absolutePath), { recursive: true });
|
|
71
|
+
await writeFile(absolutePath, content, "utf8");
|
|
72
|
+
createdFiles.push(relativePath);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const gitignoreUpdated = await appendGitignoreEntries(
|
|
76
|
+
path.join(projectRoot, ".gitignore"),
|
|
77
|
+
LOCAL_GITIGNORE_ENTRIES,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
createdFiles,
|
|
82
|
+
createdDirs,
|
|
83
|
+
gitignoreUpdated,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const UNINSTALLABLE_BOOTSTRAP_PREFIXES = [
|
|
88
|
+
".nimi/config/",
|
|
89
|
+
".nimi/contracts/",
|
|
90
|
+
".nimi/methodology/",
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
function isUninstallableBootstrapPath(relativePath) {
|
|
94
|
+
return UNINSTALLABLE_BOOTSTRAP_PREFIXES.some((prefix) => relativePath.startsWith(prefix));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function collectBootstrapRemovalState(projectRoot) {
|
|
98
|
+
const removableFiles = [];
|
|
99
|
+
const preservedModifiedFiles = [];
|
|
100
|
+
const seedMap = await createBootstrapSeedFileMap();
|
|
101
|
+
|
|
102
|
+
for (const [relativePath, content] of seedMap.entries()) {
|
|
103
|
+
if (!isUninstallableBootstrapPath(relativePath)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const absolutePath = path.join(projectRoot, relativePath);
|
|
108
|
+
const info = await pathExists(absolutePath);
|
|
109
|
+
if (!info || !info.isFile()) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const actual = await readFile(absolutePath, "utf8");
|
|
114
|
+
if (actual === content) {
|
|
115
|
+
removableFiles.push(relativePath);
|
|
116
|
+
} else {
|
|
117
|
+
preservedModifiedFiles.push(relativePath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
removableFiles,
|
|
123
|
+
preservedModifiedFiles,
|
|
124
|
+
hasWork: removableFiles.length > 0 || preservedModifiedFiles.length > 0,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function removeEmptyBootstrapDirs(projectRoot) {
|
|
129
|
+
const removableDirs = [
|
|
130
|
+
".nimi/config",
|
|
131
|
+
".nimi/contracts",
|
|
132
|
+
".nimi/methodology",
|
|
133
|
+
];
|
|
134
|
+
const removedDirs = [];
|
|
135
|
+
|
|
136
|
+
for (const relativeDir of removableDirs) {
|
|
137
|
+
const absoluteDir = path.join(projectRoot, relativeDir);
|
|
138
|
+
const info = await pathExists(absoluteDir);
|
|
139
|
+
if (!info || !info.isDirectory()) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const entries = await readdir(absoluteDir);
|
|
144
|
+
if (entries.length > 0) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
await rmdir(absoluteDir);
|
|
149
|
+
removedDirs.push(relativeDir);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return removedDirs;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function previewBootstrapRemoval(projectRoot) {
|
|
156
|
+
return collectBootstrapRemovalState(projectRoot);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export async function removeManagedBootstrapFiles(projectRoot) {
|
|
160
|
+
const state = await collectBootstrapRemovalState(projectRoot);
|
|
161
|
+
|
|
162
|
+
for (const relativePath of state.removableFiles) {
|
|
163
|
+
await rm(path.join(projectRoot, relativePath), { force: true });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const removedDirs = await removeEmptyBootstrapDirs(projectRoot);
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
removedFiles: state.removableFiles,
|
|
170
|
+
removedDirs,
|
|
171
|
+
preservedModifiedFiles: state.preservedModifiedFiles,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function inspectBootstrapCompatibility(projectRoot) {
|
|
176
|
+
const bootstrapConfigPath = path.join(projectRoot, ".nimi", "config", "bootstrap.yaml");
|
|
177
|
+
const bootstrapConfigText = await readTextIfFile(bootstrapConfigPath);
|
|
178
|
+
|
|
179
|
+
if (!bootstrapConfigText) {
|
|
180
|
+
return {
|
|
181
|
+
status: "missing",
|
|
182
|
+
initializedBy: null,
|
|
183
|
+
contractId: null,
|
|
184
|
+
contractVersion: null,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const initializedBy = readYamlScalar(bootstrapConfigText, "initialized_by");
|
|
189
|
+
const contractId = readYamlScalar(bootstrapConfigText, "bootstrap_contract");
|
|
190
|
+
const contractVersion = readYamlScalar(bootstrapConfigText, "bootstrap_contract_version");
|
|
191
|
+
|
|
192
|
+
if (!contractId && !contractVersion) {
|
|
193
|
+
return {
|
|
194
|
+
status: initializedBy === PACKAGE_NAME ? "legacy" : "unsupported",
|
|
195
|
+
initializedBy,
|
|
196
|
+
contractId,
|
|
197
|
+
contractVersion,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (initializedBy !== PACKAGE_NAME) {
|
|
202
|
+
return {
|
|
203
|
+
status: "unsupported",
|
|
204
|
+
initializedBy,
|
|
205
|
+
contractId,
|
|
206
|
+
contractVersion,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (
|
|
211
|
+
contractId !== BOOTSTRAP_CONTRACT_ID
|
|
212
|
+
|| contractVersion !== String(BOOTSTRAP_CONTRACT_VERSION)
|
|
213
|
+
) {
|
|
214
|
+
return {
|
|
215
|
+
status: "unsupported",
|
|
216
|
+
initializedBy,
|
|
217
|
+
contractId,
|
|
218
|
+
contractVersion,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
status: "supported",
|
|
224
|
+
initializedBy,
|
|
225
|
+
contractId,
|
|
226
|
+
contractVersion,
|
|
227
|
+
};
|
|
228
|
+
}
|