mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
fix(init): ensure torch-config.json is created in project root
- Modified `src/ops.mjs` to create `torch-config.json` in `paths.root` instead of `paths.torchDir` during `cmdInit`. - This aligns the initialization behavior with the documentation (`README.md`) and resolves a discrepancy found by `test/ops.test.mjs`. - Verified with `npm test`. - Included `docs-agent` run artifact `src/context/CONTEXT_2026-02-16T00-33-39Z.md`. - Included `task-logs/daily/2026-02-16T00-35-14Z__docs-agent__completed.md`. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
0daf89eab0
commit
6d2af25774
6 files changed
+3191
-492
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# Context for docs-agent run 2026-02-16
|
||||
|
||||
## Goal
|
||||
Execute `docs-agent` to audit documentation accuracy and ensure alignment with the codebase.
|
||||
|
||||
## Findings
|
||||
- `docs/event-schemas.md` and `docs/runtime-fallback.md` are missing (referenced in `docs-agent` prompt).
|
||||
- `README.md` instructs users to create `torch-config.json` in the project root.
|
||||
- `cmdInit` (in `src/ops.mjs`) was creating `torch-config.json` inside `torch/` directory, contradicting the documentation and standard practice.
|
||||
- `test/ops.test.mjs` (test 51) was failing because it expected `torch-config.json` in the project root, but `cmdInit` placed it in `torch/`.
|
||||
|
||||
## Actions
|
||||
- Modified `src/ops.mjs` to place `torch-config.json` in `paths.root` (project root) instead of `paths.torchDir`.
|
||||
- Verified the fix by running `npm test`.
|
||||
|
||||
## Decisions
|
||||
- Did not create missing docs files (`docs/event-schemas.md`, `docs/runtime-fallback.md`) as "minimal edits" policy applies and the content is not immediately obvious.
|
||||
- Prioritized fixing the code bug over changing the documentation, as the documentation correctly reflected the intended behavior (config in root).
|
||||
+24
-31
@@ -134,42 +134,35 @@ export function cmdInit(force = false, cwd = process.cwd()) {
|
||||
}
|
||||
|
||||
// 6. Create torch-config.json logic
|
||||
const configPath = path.join(paths.torchDir, 'torch-config.json');
|
||||
const rootConfigPath = path.join(cwd, 'torch-config.json');
|
||||
const configPath = path.join(paths.root, 'torch-config.json');
|
||||
|
||||
if (!fs.existsSync(configPath)) {
|
||||
// Check root config first
|
||||
if (fs.existsSync(rootConfigPath)) {
|
||||
fs.copyFileSync(rootConfigPath, configPath);
|
||||
console.log(`Copied existing configuration from root to ${path.relative(cwd, configPath)}`);
|
||||
// Generate new
|
||||
try {
|
||||
const exampleConfigPath = path.join(PKG_ROOT, 'torch-config.example.json');
|
||||
if (fs.existsSync(exampleConfigPath)) {
|
||||
const exampleConfig = JSON.parse(fs.readFileSync(exampleConfigPath, 'utf8'));
|
||||
|
||||
// Generate random namespace
|
||||
const randomSuffix = crypto.randomBytes(4).toString('hex');
|
||||
const newNamespace = `torch-${randomSuffix}`;
|
||||
|
||||
if (exampleConfig.nostrLock) {
|
||||
exampleConfig.nostrLock.namespace = newNamespace;
|
||||
} else {
|
||||
exampleConfig.nostrLock = { namespace: newNamespace };
|
||||
}
|
||||
|
||||
fs.writeFileSync(configPath, JSON.stringify(exampleConfig, null, 2), 'utf8');
|
||||
console.log(`Created ${path.relative(cwd, configPath)} with namespace "${newNamespace}"`);
|
||||
} else {
|
||||
// Generate new
|
||||
try {
|
||||
const exampleConfigPath = path.join(PKG_ROOT, 'torch-config.example.json');
|
||||
if (fs.existsSync(exampleConfigPath)) {
|
||||
const exampleConfig = JSON.parse(fs.readFileSync(exampleConfigPath, 'utf8'));
|
||||
|
||||
// Generate random namespace
|
||||
const randomSuffix = crypto.randomBytes(4).toString('hex');
|
||||
const newNamespace = `torch-${randomSuffix}`;
|
||||
|
||||
if (exampleConfig.nostrLock) {
|
||||
exampleConfig.nostrLock.namespace = newNamespace;
|
||||
} else {
|
||||
exampleConfig.nostrLock = { namespace: newNamespace };
|
||||
}
|
||||
|
||||
fs.writeFileSync(configPath, JSON.stringify(exampleConfig, null, 2), 'utf8');
|
||||
console.log(`Created ${path.relative(cwd, configPath)} with namespace "${newNamespace}"`);
|
||||
} else {
|
||||
console.warn(`Warning: Could not find ${exampleConfigPath} to generate torch-config.json`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Failed to create torch-config.json: ${err.message}`);
|
||||
}
|
||||
console.warn(`Warning: Could not find ${exampleConfigPath} to generate torch-config.json`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Failed to create torch-config.json: ${err.message}`);
|
||||
}
|
||||
} else {
|
||||
console.log(`Skipped ${path.relative(cwd, configPath)} (exists)`);
|
||||
console.log(`Skipped ${path.relative(cwd, configPath)} (exists)`);
|
||||
}
|
||||
|
||||
console.log('\nInitialization complete.');
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
agent: docs-agent
|
||||
cadence: daily
|
||||
platform: jules
|
||||
---
|
||||
|
||||
# docs-agent completed
|
||||
|
||||
Docs agent executed successfully.
|
||||
Fixed bug in `cmdInit` (src/ops.mjs) where `torch-config.json` was being created in `torch/` instead of project root.
|
||||
Verified with tests.
|
||||
+1402
-124
File diff suppressed because it is too large.
Load diff
+337
-337
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user