@aiwg/cli 2026.10.14 → 2026.10.16
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/agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md +13 -0
- package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +118 -0
- package/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
- package/dist/src/artifacts/citation-parser.js +7 -6
- package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
- package/dist/src/artifacts/corpus-tools/cli.js +37 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +27 -25
- package/dist/src/artifacts/corpus-tools/expand-cli.js +90 -0
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +41 -0
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +56 -0
- package/dist/src/artifacts/corpus-tools/expand.js +124 -0
- package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
- package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
- package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +99 -0
- package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +119 -0
- package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
- package/dist/src/artifacts/graph-query.js +5 -3
- package/dist/src/artifacts/hybrid-query.js +11 -2
- package/dist/src/artifacts/index-refresh.js +2 -0
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +45 -0
- package/dist/src/cli/handlers/doctor-help.js +8 -3
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +3 -2
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands.js +8 -0
- package/dist/src/cli/handlers/update.js +157 -0
- package/dist/src/cli/handlers/use.js +14 -4
- package/dist/src/cli/handlers/utilities.js +3 -586
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +17 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +19 -0
- package/dist/src/config/host-resource-report.mjs +80 -0
- package/dist/src/config/host-resource-runtime.d.mts +34 -0
- package/dist/src/config/host-resource-runtime.mjs +293 -0
- package/dist/src/config/installed-selection.js +22 -0
- package/dist/src/config/worker-context.js +33 -4
- package/dist/src/config/worker-invocation-marker.d.mts +1 -0
- package/dist/src/config/worker-invocation-marker.mjs +2 -0
- package/dist/src/decision/heldout/access.js +74 -0
- package/dist/src/decision/heldout/calibration.js +1 -0
- package/dist/src/decision/heldout/collector.js +9 -2
- package/dist/src/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +115 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/features/catalog.js +1 -1
- package/dist/src/gates/evaluate.js +2 -2
- package/dist/src/gates/heldout.js +52 -0
- package/dist/src/gates/index.js +2 -1
- package/dist/src/lint/check-patterns.js +163 -0
- package/dist/src/lint/checks.js +268 -0
- package/dist/src/lint/reference-resolution.js +54 -0
- package/dist/src/lint/runner.js +3 -465
- package/dist/src/mcp/helpers.mjs +11 -1
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/models/worker-installation-store.mjs +228 -0
- package/dist/src/models/worker-installation.mjs +7 -162
- package/dist/src/models/worker-plan.js +36 -5
- package/dist/src/models/wrapper-deployment.js +25 -12
- package/dist/src/models/wrapper-enforcement.js +47 -7
- package/dist/src/network-analysis/research.js +2 -1
- package/dist/src/policy/hitl-check.js +14 -4
- package/dist/src/policy/hitl-consume.js +54 -0
- package/dist/src/policy/hitl-receipt.js +2 -0
- package/dist/src/policy/hitl.js +11 -3
- package/dist/src/providers/provider-context-contracts.js +162 -0
- package/dist/src/providers/provider-definition-schema.js +136 -0
- package/dist/src/providers/provider-definitions.js +8 -1298
- package/dist/src/providers/provider-seeds-1.js +360 -0
- package/dist/src/providers/provider-seeds-2.js +387 -0
- package/dist/src/providers/provider-seeds-3.js +262 -0
- package/dist/src/research/clients/arxiv.js +14 -34
- package/dist/src/research/clients/base.js +53 -26
- package/dist/src/research/clients/crossref.js +9 -1
- package/dist/src/research/clients/semantic-scholar.js +73 -44
- package/dist/src/research/identity.js +117 -0
- package/dist/src/research/index.js +1 -0
- package/dist/src/research/query-cli.js +3 -87
- package/dist/src/research/query-options.js +87 -0
- package/dist/src/research/reference-match.js +135 -0
- package/dist/src/research/services/acquisition.js +9 -7
- package/dist/src/research/services/citation.js +5 -2
- package/dist/src/research/types.js +2 -0
- package/dist/src/rules/core-startup.d.mts +2 -0
- package/dist/src/rules/core-startup.mjs +31 -0
- package/dist/src/serve/mission-conductor.js +48 -4
- package/dist/src/sessions/adapters/grok-build-native.js +23 -0
- package/dist/src/sessions/adapters/grok-build.js +14 -7
- package/dist/src/sessions/workspace-discovery.js +5 -5
- package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +19 -46
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +49 -114
- package/dist/src/smiths/context-pipeline/managed-hook.js +11 -1
- package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
- package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
- package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
- package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
- package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
- package/package.json +13 -2
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +12 -123
- package/tools/agents/providers/antigravity.mjs +1 -1
- package/tools/agents/providers/claude-post-deploy.mjs +12 -1
- package/tools/agents/providers/context-write.mjs +16 -0
- package/tools/agents/providers/grok-build.mjs +8 -5
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
- package/tools/agents/providers/hermes-startup.mjs +209 -0
- package/tools/agents/providers/hermes.mjs +9 -359
- package/tools/agents/providers/model-wrapper.mjs +5 -1
- package/tools/agents/providers/muse.mjs +3 -3
- package/tools/agents/providers/pi.mjs +4 -2
- package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1346
- package/tools/agents/providers/rule-deployment-commit.mjs +144 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +452 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/agents/providers/rule-presentation.mjs +13 -4
- package/tools/agents/providers/rule-projection.mjs +119 -0
- package/tools/agents/providers/rule-startup.mjs +70 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
- package/tools/agents/providers/warp.mjs +2 -2
- package/tools/agents/providers/windsurf.mjs +11 -57
- package/tools/daemon/README.md +511 -0
- package/tools/daemon/adapters/base-adapter.mjs +84 -0
- package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
- package/tools/daemon/agent-supervisor.mjs +299 -0
- package/tools/daemon/automation-engine.mjs +310 -0
- package/tools/daemon/autonomous-engine.mjs +346 -0
- package/tools/daemon/behavior-loader.mjs +316 -0
- package/tools/daemon/behavior.mjs +174 -0
- package/tools/daemon/concierge/intent-router.mjs +401 -0
- package/tools/daemon/concierge/orchestrator.mjs +272 -0
- package/tools/daemon/concierge/response-translator.mjs +462 -0
- package/tools/daemon/config.mjs +377 -0
- package/tools/daemon/cron-scheduler.mjs +178 -0
- package/tools/daemon/daemon-main.mjs +1169 -0
- package/tools/daemon/event-router.mjs +84 -0
- package/tools/daemon/file-watcher.mjs +383 -0
- package/tools/daemon/index.mjs +1181 -0
- package/tools/daemon/init-profile.mjs +124 -0
- package/tools/daemon/ipc-client.mjs +197 -0
- package/tools/daemon/ipc-ops-handlers.mjs +236 -0
- package/tools/daemon/ipc-server.mjs +275 -0
- package/tools/daemon/maintenance-owner.mjs +79 -0
- package/tools/daemon/memory-manager.mjs +386 -0
- package/tools/daemon/message-router.mjs +194 -0
- package/tools/daemon/provider-watcher.mjs +585 -0
- package/tools/daemon/pty-adapter.mjs +420 -0
- package/tools/daemon/repl-chat.mjs +359 -0
- package/tools/daemon/resource-bounds.mjs +88 -0
- package/tools/daemon/sandbox-transport.mjs +295 -0
- package/tools/daemon/scheduled-task-runner.mjs +535 -0
- package/tools/daemon/task-store.mjs +450 -0
- package/tools/daemon/tmux-manager.mjs +324 -0
- package/tools/daemon/update-policy.mjs +517 -0
- package/tools/daemon/web-server.mjs +399 -0
- package/tools/daemon/web-ui/index.html +585 -0
- package/tools/daemon/web-ui/styles.css +156 -0
- package/tools/docker/Dockerfile.daemon +35 -0
- package/tools/docker/container-manager.mjs +291 -0
- package/tools/messaging/adapter-registry.mjs +230 -0
- package/tools/messaging/adapters/base.mjs +326 -0
- package/tools/messaging/adapters/discord.mjs +462 -0
- package/tools/messaging/adapters/slack.mjs +402 -0
- package/tools/messaging/adapters/telegram.mjs +552 -0
- package/tools/messaging/chat-handler.mjs +297 -0
- package/tools/messaging/command-router.mjs +269 -0
- package/tools/messaging/event-bus.mjs +199 -0
- package/tools/messaging/index.mjs +456 -0
- package/tools/messaging/message-formatter.mjs +320 -0
- package/tools/messaging/room-manager.mjs +277 -0
- package/tools/messaging/types.mjs +94 -0
- package/tools/plugin/plugin-links.mjs +3 -0
- package/tools/providers/pi-bridge-policy.mjs +4 -0
- package/tools/ralph-external/daemon-supervisor.mjs +394 -0
- package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +3 -2
- package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
- package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
- package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Parse the corpus resolve arguments, emit per-reference results, and preserve semantic exit codes.
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { AiwgError } from '../../cli/errors.js';
|
|
5
|
+
import { ResearchError, ResearchErrorCode } from '../../research/types.js';
|
|
6
|
+
import { createResolverClients, resolveReference } from './resolve.js';
|
|
7
|
+
export const RESOLVE_USAGE = 'aiwg corpus resolve "<title | URL | arXiv ID | DOI | bibliography line>" [--year YYYY] [--json]\naiwg corpus resolve --from-file refs.txt [--year YYYY] [--json]\nExit codes: 0 resolved, 2 ambiguous, 3 unresolved, 4 deferred (incomplete lookup; retry), 1 usage or storage error (batch: worst line).\n';
|
|
8
|
+
function usage(message) {
|
|
9
|
+
throw new AiwgError({ code: 'ERR_CORPUS_RESOLVE_USAGE', message, exitCode: 1, hint: RESOLVE_USAGE.trim() });
|
|
10
|
+
}
|
|
11
|
+
function render(result) {
|
|
12
|
+
const lines = [`${result.line ? `Line ${result.line}: ` : ''}${result.status}: ${result.input}`];
|
|
13
|
+
for (const candidate of result.candidates)
|
|
14
|
+
lines.push(` ${candidate.score.toFixed(3)} ${candidate.paper.title} (${candidate.paper.id})`);
|
|
15
|
+
for (const finding of result.findings)
|
|
16
|
+
lines.push(` Finding ${finding.type}: supplied "${finding.supplied}"; returned "${finding.returned}"`);
|
|
17
|
+
for (const match of result.corpus_matches)
|
|
18
|
+
lines.push(` Already in corpus: ${match.ref} (${match.matched_by.join(', ')})`);
|
|
19
|
+
for (const path of result.paths_tried)
|
|
20
|
+
lines.push(` Tried ${path.source}/${path.method}: ${path.query} → ${path.status} (${path.returned.length})${path.error ? `: ${path.error}` : ''}`);
|
|
21
|
+
if (result.incomplete)
|
|
22
|
+
lines.push(` Incomplete${result.error ? `: ${result.error}` : ''}`);
|
|
23
|
+
return lines.join('\n') + '\n';
|
|
24
|
+
}
|
|
25
|
+
export async function resolveCli(args, root, cwd) {
|
|
26
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
27
|
+
process.stdout.write(RESOLVE_USAGE);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let input;
|
|
31
|
+
let fromFile;
|
|
32
|
+
let year;
|
|
33
|
+
let json = false;
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
for (let i = 0; i < args.length; i++) {
|
|
36
|
+
const arg = args[i];
|
|
37
|
+
if (arg.startsWith('--')) {
|
|
38
|
+
if (seen.has(arg))
|
|
39
|
+
usage(`${arg} may only be supplied once`);
|
|
40
|
+
seen.add(arg);
|
|
41
|
+
}
|
|
42
|
+
if (arg === '--json') {
|
|
43
|
+
json = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (arg === '--year' || arg === '--from-file') {
|
|
47
|
+
const value = args[++i];
|
|
48
|
+
if (!value || value.startsWith('--'))
|
|
49
|
+
usage(`${arg} requires a value`);
|
|
50
|
+
if (arg === '--from-file') {
|
|
51
|
+
if (fromFile)
|
|
52
|
+
usage('--from-file may only be supplied once');
|
|
53
|
+
fromFile = value;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (year !== undefined || !/^(?:18|19|20|21)\d{2}$/.test(value))
|
|
57
|
+
usage('--year requires one year between 1800 and 2199');
|
|
58
|
+
year = Number(value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (arg.startsWith('-'))
|
|
63
|
+
usage(`Unknown resolve option: ${arg}`);
|
|
64
|
+
if (input !== undefined)
|
|
65
|
+
usage('Supply one quoted reference');
|
|
66
|
+
input = arg;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (input !== undefined && fromFile)
|
|
70
|
+
usage('A reference and --from-file are mutually exclusive');
|
|
71
|
+
if (!fromFile && !input?.trim())
|
|
72
|
+
usage('Supply a reference or --from-file');
|
|
73
|
+
const references = fromFile ? readFileSync(resolve(cwd, fromFile), 'utf8').split(/\r?\n/)
|
|
74
|
+
.flatMap((text, index) => text.trim() ? [{ input: text.trim(), line: index + 1 }] : []) : [{ input: input }];
|
|
75
|
+
const clients = createResolverClients();
|
|
76
|
+
const results = [];
|
|
77
|
+
for (const reference of references) {
|
|
78
|
+
try {
|
|
79
|
+
results.push({ ...await resolveReference(reference.input, root, year, clients), ...reference });
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// Storage, validation and programming errors keep the corpus error/exit convention.
|
|
83
|
+
if (!(error instanceof ResearchError) || ![
|
|
84
|
+
ResearchErrorCode.RF_103, ResearchErrorCode.RF_104,
|
|
85
|
+
ResearchErrorCode.RF_200, ResearchErrorCode.RF_201, ResearchErrorCode.RF_202,
|
|
86
|
+
ResearchErrorCode.RF_500, ResearchErrorCode.RF_501, ResearchErrorCode.RF_502,
|
|
87
|
+
].includes(error.code))
|
|
88
|
+
throw error;
|
|
89
|
+
results.push({ ...reference, reference: { input: reference.input }, status: 'deferred', incomplete: true,
|
|
90
|
+
error: error instanceof Error ? error.message : String(error), candidates: [], findings: [], paths_tried: [],
|
|
91
|
+
already_in_corpus: false, corpus_matches: [] });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
process.stdout.write(json ? JSON.stringify(fromFile ? results : results[0], null, 2) + '\n' : results.map(render).join('\n'));
|
|
95
|
+
const exitCode = results.reduce((worst, result) => Math.max(worst, { resolved: 0, ambiguous: 2, unresolved: 3, deferred: 4 }[result.status]), 0);
|
|
96
|
+
if (exitCode)
|
|
97
|
+
throw new AiwgError({ code: 'ERR_CORPUS_RESOLVE_RESULT', message: 'Reference resolution requires review; see results', exitCode });
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=resolve-cli.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Reuse the corpus readers to locate identities in reference and citation frontmatter.
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { loadCorpus, parseFrontmatter } from '../corpus-views/ref-parser.js';
|
|
5
|
+
import { identityKeys, parseResearchIdentifier } from '../../research/identity.js';
|
|
6
|
+
/** Build once for expansion; resolve retains the same ID/title matching contract. */
|
|
7
|
+
export function loadCorpusIdentities(root) {
|
|
8
|
+
return loadCorpus(root).records.map(record => {
|
|
9
|
+
const keys = new Set(identityKeys({ title: record.title }));
|
|
10
|
+
const fields = [];
|
|
11
|
+
let bodyArxiv;
|
|
12
|
+
for (const file of [record.path, join(root, 'documentation', 'citations', `${record.refId}-citations.md`)]) {
|
|
13
|
+
if (!existsSync(file))
|
|
14
|
+
continue;
|
|
15
|
+
const text = readFileSync(file, 'utf8');
|
|
16
|
+
const fm = parseFrontmatter(text);
|
|
17
|
+
fields.push(fm);
|
|
18
|
+
for (const key of identityKeys(fm))
|
|
19
|
+
keys.add(key);
|
|
20
|
+
for (const url of text.match(/https?:\/\/(?:export\.)?arxiv\.org\/(?:abs|pdf|html)\/[^\s<>\]\)]+/gi) ?? []) {
|
|
21
|
+
const id = parseResearchIdentifier(url);
|
|
22
|
+
if (id?.kind === 'arxiv') {
|
|
23
|
+
bodyArxiv ??= id.id;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Other body links may cite unheld papers; only a missing primary ID needs this fallback.
|
|
29
|
+
if (bodyArxiv && ![...keys].some(key => key.startsWith('arxivId:') || key.startsWith('doi:')))
|
|
30
|
+
keys.add(`arxivId:${bodyArxiv}`);
|
|
31
|
+
return { ref: record.refId, path: record.path, fields, keys };
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function findInCorpus(root, paper, index = loadCorpusIdentities(root)) {
|
|
35
|
+
const wanted = new Set(identityKeys(paper));
|
|
36
|
+
return index.flatMap(record => {
|
|
37
|
+
const matched = [...record.keys].filter(key => wanted.has(key)).map(key => key.slice(0, key.indexOf(':')));
|
|
38
|
+
return matched.length ? [{ ref: record.ref, matched_by: [...new Set(matched)] }] : [];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=resolve-corpus.js.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Resolve partial paper references through audited client attempts and conservative scoring.
|
|
2
|
+
import { ArxivClient } from '../../research/clients/arxiv.js';
|
|
3
|
+
import { CrossRefClient } from '../../research/clients/crossref.js';
|
|
4
|
+
import { SemanticScholarClient } from '../../research/clients/semantic-scholar.js';
|
|
5
|
+
import { identityKeys, normalizeIdentity, normalizeTitle } from '../../research/identity.js';
|
|
6
|
+
import { classifyCandidates, mergePapers, needsTitleDisambiguation, parsePartialReference, scorePaper } from '../../research/reference-match.js';
|
|
7
|
+
import { ResearchError, ResearchErrorCode } from '../../research/types.js';
|
|
8
|
+
import { findInCorpus } from './resolve-corpus.js';
|
|
9
|
+
export function createResolverClients() {
|
|
10
|
+
return { arxiv: new ArxivClient(), s2: new SemanticScholarClient(), crossref: new CrossRefClient() };
|
|
11
|
+
}
|
|
12
|
+
function canonicalPaper(paper) {
|
|
13
|
+
const identity = normalizeIdentity(paper);
|
|
14
|
+
const validYear = (value) => Number.isInteger(value) && value >= 1000 && value <= 2199;
|
|
15
|
+
const year = validYear(paper.year) ? paper.year : Number(paper.publicationDate?.slice(0, 4));
|
|
16
|
+
if (!validYear(year))
|
|
17
|
+
throw new ResearchError(ResearchErrorCode.RF_301, 'Response lacks a valid publication year');
|
|
18
|
+
// Keep source spelling in results; normalizeIdentity supplies case-insensitive keys.
|
|
19
|
+
return { ...paper, year, ...Object.fromEntries(Object.entries(identity)
|
|
20
|
+
.filter(([key, value]) => !['title', 'openReviewId', 'aclId'].includes(key) && value !== undefined)) };
|
|
21
|
+
}
|
|
22
|
+
function s2Identifier(identifier) {
|
|
23
|
+
switch (identifier.kind) {
|
|
24
|
+
case 'arxiv': return `ARXIV:${identifier.id}`;
|
|
25
|
+
case 'doi': return `DOI:${identifier.id}`;
|
|
26
|
+
case 'acl': return `ACL:${identifier.id}`;
|
|
27
|
+
case 'openreview': return `URL:https://openreview.net/forum?id=${identifier.id}`;
|
|
28
|
+
case 's2': return identifier.id;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function resolveReference(input, root, year, clients = createResolverClients()) {
|
|
32
|
+
const reference = parsePartialReference(input, year);
|
|
33
|
+
const paths = [];
|
|
34
|
+
const findings = [];
|
|
35
|
+
const papers = [];
|
|
36
|
+
const verified = new Set();
|
|
37
|
+
const identifier = reference.identifier;
|
|
38
|
+
async function attempt(source, method, query, run, byId = false) {
|
|
39
|
+
try {
|
|
40
|
+
const returned = (await run()).slice(0, 5).map(canonicalPaper);
|
|
41
|
+
if (returned.some(paper => !paper.id || !normalizeTitle(paper.title))) {
|
|
42
|
+
throw new ResearchError(ResearchErrorCode.RF_301, 'Response lacks a paper identity or title');
|
|
43
|
+
}
|
|
44
|
+
paths.push({ source, method, query, status: returned.length ? 'returned' : 'empty', returned });
|
|
45
|
+
for (const paper of returned) {
|
|
46
|
+
if (byId && identifier) {
|
|
47
|
+
const key = { arxiv: 'arxivId', doi: 'doi', acl: 'aclId', openreview: 'openReviewId', s2: 's2PaperId' }[identifier.kind];
|
|
48
|
+
const actual = paper[key];
|
|
49
|
+
if (actual && identifier.kind !== 's2' && String(actual).toLowerCase() !== identifier.id.toLowerCase()) {
|
|
50
|
+
findings.push({ type: 'identifier_mismatch', supplied: identifier.id, returned: String(actual), candidate: paper.id });
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (identifier.kind === 's2' && !identifier.id.startsWith('CorpusId:') && paper.s2PaperId?.toLowerCase() !== identifier.id.toLowerCase()) {
|
|
54
|
+
findings.push({ type: 'identifier_mismatch', supplied: identifier.id, returned: paper.s2PaperId ?? paper.id, candidate: paper.id });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// A direct lookup establishes the requested ID when the API omits that externalId.
|
|
58
|
+
if (identifier.kind !== 's2')
|
|
59
|
+
Object.assign(paper, { [key]: identifier.id });
|
|
60
|
+
for (const key of identityKeys(paper).filter(key => !key.startsWith('title:')))
|
|
61
|
+
verified.add(key);
|
|
62
|
+
}
|
|
63
|
+
papers.push(paper);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
const missing = error instanceof ResearchError && error.code === ResearchErrorCode.RF_300;
|
|
68
|
+
paths.push({ source, method, query, status: missing ? 'empty' : 'error', returned: [],
|
|
69
|
+
...(missing ? {} : { error: error instanceof Error ? error.message : String(error) }) });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (identifier) {
|
|
73
|
+
if (identifier.kind === 'arxiv') {
|
|
74
|
+
await attempt('arxiv', 'id', identifier.id, async () => [await clients.arxiv.getPaperById(identifier.id)], true);
|
|
75
|
+
}
|
|
76
|
+
else if (identifier.kind === 'doi') {
|
|
77
|
+
await attempt('crossref', 'id', identifier.id, async () => [await clients.crossref.getPaperByDoi(identifier.id)], true);
|
|
78
|
+
}
|
|
79
|
+
const id = s2Identifier(identifier);
|
|
80
|
+
await attempt('semantic-scholar', 'id', id, async () => [await clients.s2.getPaperById(id)], true);
|
|
81
|
+
}
|
|
82
|
+
const identifierUnresolved = Boolean(identifier && verified.size === 0);
|
|
83
|
+
if (identifierUnresolved && identifier) {
|
|
84
|
+
const idPaths = paths.filter(path => path.method === 'id');
|
|
85
|
+
findings.push({ type: 'identifier_unresolved', supplied: identifier.id, paths: idPaths,
|
|
86
|
+
returned: idPaths.map(path => {
|
|
87
|
+
const detail = path.error ?? path.returned.map(paper => JSON.stringify({ ...normalizeIdentity(paper),
|
|
88
|
+
openReviewId: paper.openReviewId, aclId: paper.aclId })).join(', ');
|
|
89
|
+
const outcome = path.returned.length ? 'returned (identifier mismatch)' : path.status;
|
|
90
|
+
return `${path.source}/${path.method} (${path.query}): ${outcome}${detail ? `: ${detail}` : ''}`;
|
|
91
|
+
}).join('; ') });
|
|
92
|
+
}
|
|
93
|
+
if (reference.title && (!identifier || papers.length === 0)) {
|
|
94
|
+
await attempt('semantic-scholar', 'title-match', reference.title, () => clients.s2.matchTitle(reference.title));
|
|
95
|
+
const query = `ti:"${normalizeTitle(reference.title)}"`;
|
|
96
|
+
await attempt('arxiv', 'title', query, async () => (await clients.arxiv.search(query, { limit: 5 })).papers);
|
|
97
|
+
await attempt('crossref', 'bibliographic', input, async () => (await clients.crossref.searchBibliographic(input, { limit: 5 })).papers);
|
|
98
|
+
}
|
|
99
|
+
const candidates = mergePapers(papers).map(paper => scorePaper(reference, paper, identityKeys(paper).some(key => verified.has(key))))
|
|
100
|
+
.sort((a, b) => b.score - a.score || a.paper.id.localeCompare(b.paper.id)).slice(0, 5);
|
|
101
|
+
for (const candidate of candidates.slice(0, 1)) {
|
|
102
|
+
if (reference.title && normalizeTitle(reference.title) !== normalizeTitle(candidate.paper.title)) {
|
|
103
|
+
findings.push({ type: 'title_mismatch', supplied: reference.title, returned: candidate.paper.title, candidate: candidate.paper.id });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const classified = classifyCandidates(candidates);
|
|
107
|
+
const incomplete = paths.some(path => path.status === 'error');
|
|
108
|
+
const titleAmbiguous = needsTitleDisambiguation(reference, candidates, incomplete);
|
|
109
|
+
const status = classified === 'unresolved' && incomplete ? 'deferred'
|
|
110
|
+
: classified === 'resolved' && (identifierUnresolved || titleAmbiguous) ? 'ambiguous' : classified;
|
|
111
|
+
if (titleAmbiguous && classified !== 'unresolved')
|
|
112
|
+
findings.push({ type: 'title_ambiguous',
|
|
113
|
+
supplied: reference.title, returned: 'Supply a year, author, or verified identifier to disambiguate this title' });
|
|
114
|
+
const paper = status === 'resolved' ? candidates[0].paper : undefined;
|
|
115
|
+
const corpusMatches = paper ? findInCorpus(root, paper) : [];
|
|
116
|
+
return { input, reference, status, incomplete, candidates,
|
|
117
|
+
...(paper ? { paper } : {}), findings, paths_tried: paths, already_in_corpus: corpusMatches.length > 0, corpus_matches: corpusMatches };
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Experimental hybrid corpus-retrieval benchmark. Never replaces research-query. @issue #2038 */
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
+
import { refIdsInText } from '../../research/identity.js';
|
|
4
5
|
import path from 'node:path';
|
|
5
6
|
import { performance } from 'node:perf_hooks';
|
|
6
7
|
import { bm25Rank, tokenizeText } from '../fulltext.js';
|
|
@@ -103,7 +104,7 @@ export function parseConceptScheme(content) {
|
|
|
103
104
|
}
|
|
104
105
|
function documentId(entry) {
|
|
105
106
|
const text = [entry.name, entry.title, entry.path].filter(Boolean).join(' ');
|
|
106
|
-
return text
|
|
107
|
+
return refIdsInText(text)[0] ?? path.basename(entry.path).replace(/\.[^.]+$/, '');
|
|
107
108
|
}
|
|
108
109
|
function isResearch(entry) {
|
|
109
110
|
const candidate = `${entry.type} ${entry.path}`.toLowerCase().replaceAll('\\', '/');
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* @tests @test/unit/artifacts/sidecar-lint.test.ts
|
|
13
13
|
*/
|
|
14
14
|
import * as fs from 'fs';
|
|
15
|
+
import { REF_ID_PATTERN } from '../../research/identity.js';
|
|
16
|
+
import { refFilesForId } from './ref-files.js';
|
|
15
17
|
import * as path from 'path';
|
|
16
|
-
const REF_ID_RE =
|
|
18
|
+
const REF_ID_RE = new RegExp(REF_ID_PATTERN, 'g');
|
|
17
19
|
const CITES_DIR = ['documentation', 'citations'];
|
|
18
20
|
const REFS_DIR = ['documentation', 'references'];
|
|
19
21
|
/** List `documentation/citations/REF-*-citations.md` files under the corpus root. */
|
|
@@ -147,9 +149,7 @@ export function refTitle(root, ref) {
|
|
|
147
149
|
const refsDir = path.join(root, ...REFS_DIR);
|
|
148
150
|
if (!fs.existsSync(refsDir))
|
|
149
151
|
return '?';
|
|
150
|
-
const match =
|
|
151
|
-
.readdirSync(refsDir)
|
|
152
|
-
.find((f) => f === `${ref}.md` || f.startsWith(`${ref}-`));
|
|
152
|
+
const match = refFilesForId(refsDir, ref)[0];
|
|
153
153
|
if (!match)
|
|
154
154
|
return '?';
|
|
155
155
|
const text = fs.readFileSync(path.join(refsDir, match), 'utf-8');
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* @tests @test/unit/artifacts/sidecar-repair.test.ts
|
|
13
13
|
*/
|
|
14
14
|
import * as fs from 'fs';
|
|
15
|
+
import { refFilesForId } from './ref-files.js';
|
|
15
16
|
import * as path from 'path';
|
|
16
17
|
import { load as loadYaml } from 'js-yaml';
|
|
17
18
|
import { DEFAULT_AFFILIATION_MAP, buildAffiliationReverse } from '../corpus-views/corpus-config.js';
|
|
@@ -133,7 +134,7 @@ function findAnalysisDoc(root, ref) {
|
|
|
133
134
|
const dir = path.join(root, ...REFS_DIR);
|
|
134
135
|
if (!fs.existsSync(dir))
|
|
135
136
|
return null;
|
|
136
|
-
const match =
|
|
137
|
+
const match = refFilesForId(dir, ref)[0];
|
|
137
138
|
return match ? path.join(dir, match) : null;
|
|
138
139
|
}
|
|
139
140
|
export function repairAuthors(root, opts = {}) {
|
|
@@ -15,20 +15,10 @@ import { createHash } from 'crypto';
|
|
|
15
15
|
import { load as loadYaml } from 'js-yaml';
|
|
16
16
|
import { TOPIC_PATTERNS, METHOD_PATTERNS, VENUE_PATTERNS, SIZE_PATTERNS, SIZE_TIERS, classifyFirst, classifyMany, } from './taxonomies.js';
|
|
17
17
|
import { normalizeSourceType, loadSourceTypeRegistry } from '../corpus-tools/source-types.js';
|
|
18
|
-
|
|
19
|
-
const REF_ID_RE =
|
|
18
|
+
import { refIdFromFilename as extractRefId, REF_ID_PATTERN } from '../../research/identity.js';
|
|
19
|
+
const REF_ID_RE = new RegExp(REF_ID_PATTERN, 'g');
|
|
20
20
|
const YEAR_RE = /\b(?:19|20)(\d{2})\b/;
|
|
21
|
-
|
|
22
|
-
export function refSortKey(refId) {
|
|
23
|
-
const m = refId.match(/REF-(\d+)([a-z]?)/);
|
|
24
|
-
return m ? [parseInt(m[1], 10), m[2]] : [999999, refId];
|
|
25
|
-
}
|
|
26
|
-
/** Compare two REF ids by (numeric, suffix). */
|
|
27
|
-
export function compareRefId(a, b) {
|
|
28
|
-
const [an, as_] = refSortKey(a);
|
|
29
|
-
const [bn, bs] = refSortKey(b);
|
|
30
|
-
return an !== bn ? an - bn : as_ < bs ? -1 : as_ > bs ? 1 : 0;
|
|
31
|
-
}
|
|
21
|
+
export { refSortKey, compareRefId } from '../../research/identity.js';
|
|
32
22
|
/** Title-case matching Python str.title(): cap first letter of each alpha run, lowercase the rest. */
|
|
33
23
|
export function slugToTitle(value) {
|
|
34
24
|
return value.replace(/-/g, ' ').replace(/_/g, ' ').replace(/[A-Za-z]+/g, (w) => w[0].toUpperCase() + w.slice(1).toLowerCase());
|
|
@@ -53,10 +43,6 @@ export function parseFrontmatter(text) {
|
|
|
53
43
|
return {};
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
|
-
function extractRefId(filename) {
|
|
57
|
-
const m = filename.match(REF_FILE_RE);
|
|
58
|
-
return m ? `REF-${m[1]}` : null;
|
|
59
|
-
}
|
|
60
46
|
function extractTitle(text, fm) {
|
|
61
47
|
if (typeof fm.title === 'string')
|
|
62
48
|
return fm.title.trim().replace(/^"|"$/g, '');
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* @source @src/artifacts/types.ts
|
|
9
9
|
* @tests @test/unit/artifacts/graph-query.test.ts
|
|
10
10
|
*/
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { isRefId, refIdFromFilename } from '../research/identity.js';
|
|
11
13
|
import { normalizeEdges } from './types.js';
|
|
12
14
|
import { buildFortemiCoreDependencyGraph, loadFortemiCoreMetadataEntries } from './fortemi-core-query-adapter.js';
|
|
13
15
|
import { closeGraphBackend, openGraphBackend } from './backend-runtime.js';
|
|
@@ -57,7 +59,7 @@ export function getNeighbors(graph, node, direction = 'both', edgeType, metadata
|
|
|
57
59
|
*
|
|
58
60
|
* Supports:
|
|
59
61
|
* - Exact path match ("documentation/citations/REF-008-citations.md")
|
|
60
|
-
* - REF-XXX shorthand — finds
|
|
62
|
+
* - REF-XXX shorthand — finds a key with the exact REF filename token
|
|
61
63
|
* - Partial path match — finds the first key ending with the given string
|
|
62
64
|
*/
|
|
63
65
|
export function resolveNode(graph, node) {
|
|
@@ -65,8 +67,8 @@ export function resolveNode(graph, node) {
|
|
|
65
67
|
if (graph[node])
|
|
66
68
|
return node;
|
|
67
69
|
// REF-XXX shorthand
|
|
68
|
-
if (
|
|
69
|
-
const key = Object.keys(graph).find(k =>
|
|
70
|
+
if (isRefId(node)) {
|
|
71
|
+
const key = Object.keys(graph).find(k => refIdFromFilename(path.basename(k)) === node);
|
|
70
72
|
return key ?? null;
|
|
71
73
|
}
|
|
72
74
|
// Partial path match
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { promises as fs } from 'fs';
|
|
11
11
|
import path from 'path';
|
|
12
|
+
import { isRefId, refIdFromFilename } from '../research/identity.js';
|
|
12
13
|
import { resolveProjectAiwgDir } from '../config/project-artifacts.js';
|
|
13
14
|
// ============================================================================
|
|
14
15
|
// ArtifactIndex
|
|
@@ -109,7 +110,7 @@ export class ArtifactIndex {
|
|
|
109
110
|
*/
|
|
110
111
|
findDependents(artifactPath) {
|
|
111
112
|
const normalized = artifactPath.replace(/^\.aiwg\//, '');
|
|
112
|
-
return this.artifacts.filter((a) => a.references.some((ref) =>
|
|
113
|
+
return this.artifacts.filter((a) => a.references.some((ref) => referenceMatches(normalized, ref)));
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
116
|
* Find artifacts referenced by a given artifact.
|
|
@@ -119,7 +120,7 @@ export class ArtifactIndex {
|
|
|
119
120
|
if (!artifact)
|
|
120
121
|
return [];
|
|
121
122
|
return artifact.references
|
|
122
|
-
.map((ref) => this.artifacts.find((a) => a.relativePath
|
|
123
|
+
.map((ref) => this.artifacts.find((a) => referenceMatches(ref, a.relativePath)))
|
|
123
124
|
.filter(Boolean);
|
|
124
125
|
}
|
|
125
126
|
getAll() {
|
|
@@ -222,4 +223,12 @@ function keywordScore(artifact, query) {
|
|
|
222
223
|
}
|
|
223
224
|
return matches / terms.length;
|
|
224
225
|
}
|
|
226
|
+
/** Compare a REF token or a complete path component without substring aliases. */
|
|
227
|
+
function referenceMatches(reference, candidate) {
|
|
228
|
+
const normalized = reference.replace(/^\.aiwg\//, '');
|
|
229
|
+
const target = candidate.replace(/^\.aiwg\//, '');
|
|
230
|
+
if (isRefId(normalized))
|
|
231
|
+
return refIdFromFilename(path.basename(target)) === normalized;
|
|
232
|
+
return target === normalized || target.endsWith(`/${normalized}`);
|
|
233
|
+
}
|
|
225
234
|
//# sourceMappingURL=hybrid-query.js.map
|
|
@@ -172,6 +172,8 @@ export async function refreshResourceGate(workspace, live) {
|
|
|
172
172
|
admissionHostResources: config?.parallelism?.admission?.hostResources,
|
|
173
173
|
overlay: { max_load_ratio: 0.8 },
|
|
174
174
|
});
|
|
175
|
+
// An index refresh is not a worker launch, so the worker cap never gates it.
|
|
176
|
+
delete thresholds.max_workers;
|
|
175
177
|
const result = preflight.evaluateDispatchGate(live ?? preflight.readLiveHostResources({ paths: [workspace] }), thresholds);
|
|
176
178
|
return { ok: result.ok, reason: result.failures.map((failure) => failure.reason).join('; ') || undefined };
|
|
177
179
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Daemon Command Handlers
|
|
3
3
|
*
|
|
4
|
-
* Handlers for daemon-related CLI commands (behavior management, daemon init).
|
|
4
|
+
* Handlers for daemon-related CLI commands (lifecycle, behavior management, daemon init).
|
|
5
5
|
* Each handler delegates to existing scripts in tools/.
|
|
6
6
|
*
|
|
7
7
|
* @tests @test/unit/cli/handlers/coverage.test.ts
|
|
@@ -22,6 +22,20 @@ class DaemonHandler {
|
|
|
22
22
|
return runner.run(this.scriptPath, ctx.args);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
/** Runs the existing daemon CLI without changing its shared lifecycle state. */
|
|
26
|
+
class DaemonControlHandler extends DaemonHandler {
|
|
27
|
+
id = 'daemon';
|
|
28
|
+
name = 'Daemon';
|
|
29
|
+
description = 'Manage the daemon: start, stop, status, chat, attach and scheduled tasks';
|
|
30
|
+
scriptPath = 'tools/daemon/index.mjs';
|
|
31
|
+
async execute(ctx) {
|
|
32
|
+
const runner = createScriptRunner(await getFrameworkRoot());
|
|
33
|
+
return runner.run(this.scriptPath, ctx.args, { cwd: ctx.cwd });
|
|
34
|
+
}
|
|
35
|
+
async help(ctx) {
|
|
36
|
+
return this.execute({ ...ctx, args: ['--help'] });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
25
39
|
/**
|
|
26
40
|
* Behavior Handler
|
|
27
41
|
*
|
|
@@ -47,12 +61,14 @@ class DaemonInitHandler extends DaemonHandler {
|
|
|
47
61
|
/**
|
|
48
62
|
* Exported handler instances
|
|
49
63
|
*/
|
|
64
|
+
export const daemonHandler = new DaemonControlHandler();
|
|
50
65
|
export const behaviorHandler = new BehaviorHandler();
|
|
51
66
|
export const daemonInitHandler = new DaemonInitHandler();
|
|
52
67
|
/**
|
|
53
68
|
* All daemon handlers for registration
|
|
54
69
|
*/
|
|
55
70
|
export const daemonHandlers = [
|
|
71
|
+
daemonHandler,
|
|
56
72
|
behaviorHandler,
|
|
57
73
|
daemonInitHandler,
|
|
58
74
|
];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Validate public doctor flags before routing early-return modes.
|
|
2
|
+
import { argsTerminatorIndex, hasPositionalOrSwitch, requireFlagValue, valueTokenIndexes } from '../flag-parsing.js';
|
|
3
|
+
export function parsePublicDoctorFlags(args) {
|
|
4
|
+
const valueFlags = ['--provider', '--bundle', '--scope', '--context-baseline', '--context-budget-tokens', '--cli', '--forget-approval', '--group'];
|
|
5
|
+
const knownFlags = new Set([
|
|
6
|
+
...valueFlags, '--list-approvals', '--all-providers', '--probe-workers', '--qualify', '--yes', '--dry-run', '--no-budget-check', '--strict-context', '--json',
|
|
7
|
+
'--resources', '--decision-offload', '--deployment', '--user', '--verbose', '-v', '--project-local', '--quiet', '--help', '-h',
|
|
8
|
+
]);
|
|
9
|
+
const hasSwitch = (name) => hasPositionalOrSwitch(args, name, valueFlags);
|
|
10
|
+
const values = new Map();
|
|
11
|
+
for (const flag of valueFlags) {
|
|
12
|
+
values.set(flag, requireFlagValue(args, { rejectEmpty: true, precedence: 'last' }, flag));
|
|
13
|
+
}
|
|
14
|
+
const consumed = valueTokenIndexes(args, valueFlags);
|
|
15
|
+
for (let i = 0; i < argsTerminatorIndex(args); i += 1) {
|
|
16
|
+
const token = args[i];
|
|
17
|
+
if (consumed.has(i) || !token.startsWith('-'))
|
|
18
|
+
continue;
|
|
19
|
+
const name = token.split('=')[0];
|
|
20
|
+
if (!knownFlags.has(name) || (token.includes('=') && !valueFlags.includes(name))) {
|
|
21
|
+
throw new Error(`Unknown flag: ${name}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (values.get('--group') !== undefined && !hasSwitch('--resources'))
|
|
25
|
+
throw new Error('--group requires --resources');
|
|
26
|
+
if (hasSwitch('--resources') && (['--probe-workers', '--decision-offload', '--deployment', '--user', '--project-local'].some(hasSwitch) || values.get('--scope') !== undefined)) {
|
|
27
|
+
throw new Error('--resources must run separately from other doctor modes');
|
|
28
|
+
}
|
|
29
|
+
if (hasSwitch('--decision-offload') && (hasSwitch('--probe-workers') || hasSwitch('--deployment') || hasSwitch('--user') || values.get('--scope') !== undefined)) {
|
|
30
|
+
throw new Error('--decision-offload is a separate offline mode; do not combine it with worker, deployment or user-scope checks');
|
|
31
|
+
}
|
|
32
|
+
if (['--list-approvals', '--forget-approval', '--qualify', '--cli', '--yes', '--dry-run'].some(flag => hasSwitch(flag) || values.get(flag)) && !hasSwitch('--probe-workers')) {
|
|
33
|
+
throw new Error('--list-approvals, --forget-approval, --qualify, --cli, --yes and --dry-run require --probe-workers');
|
|
34
|
+
}
|
|
35
|
+
if ((hasSwitch('--list-approvals') || values.get('--forget-approval')) && ((hasSwitch('--list-approvals') && values.get('--forget-approval')) || ['--qualify', '--dry-run', '--resources', '--decision-offload', '--deployment', '--user'].some(hasSwitch) || values.get('--scope') !== undefined)) {
|
|
36
|
+
throw new Error('Approval management must run separately from other doctor modes');
|
|
37
|
+
}
|
|
38
|
+
if (values.get('--forget-approval') && !hasSwitch('--yes'))
|
|
39
|
+
throw new Error('--forget-approval requires --yes');
|
|
40
|
+
if (hasSwitch('--json') && !hasSwitch('--probe-workers') && !hasSwitch('--deployment') && !hasSwitch('--decision-offload') && !hasSwitch('--resources')) {
|
|
41
|
+
throw new Error('--json requires --probe-workers or --deployment or --decision-offload or --resources');
|
|
42
|
+
}
|
|
43
|
+
return { hasSwitch, values };
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=doctor-args.js.map
|
|
@@ -13,13 +13,17 @@ Options:
|
|
|
13
13
|
--scope <scope> Verification scope: project or user
|
|
14
14
|
--user Alias for --scope user
|
|
15
15
|
--qualify With --probe-workers, record installation and configured model/role approval
|
|
16
|
-
--
|
|
16
|
+
--list-approvals With --probe-workers, list recorded approvals offline (supports --json)
|
|
17
|
+
--forget-approval PATH With --probe-workers --yes, remove approvals for this workspace
|
|
18
|
+
--yes Confirm worker qualification or approval removal
|
|
17
19
|
--dry-run With --probe-workers, preview qualification without writes
|
|
18
|
-
--cli NAME Limit worker probes
|
|
20
|
+
--cli NAME Limit worker probes, qualification, or approvals to one CLI
|
|
21
|
+
--group <name> Apply the named group cap (requires --resources)
|
|
22
|
+
--resources Report live host resources, threshold origins and remaining worker slots (supports --json)
|
|
19
23
|
--decision-offload Show offline advisory decision readiness and adoption report
|
|
20
24
|
--probe-workers Run bounded worker CLI version probes (default: config-only, no subprocess)
|
|
21
25
|
--project-local Include project-local artifact diagnostics
|
|
22
|
-
--json Emit machine-readable output (with --probe-workers: one worker-probe record per CLI; with --deployment: deployment verification; with --decision-offload: offline snapshot)
|
|
26
|
+
--json Emit machine-readable output (with --probe-workers: one worker-probe record per CLI; with --deployment: deployment verification; with --decision-offload: offline snapshot; with --resources: host capacity)
|
|
23
27
|
--verbose, -v Include verbose diagnostics
|
|
24
28
|
--help, -h Show this help
|
|
25
29
|
|
|
@@ -27,6 +31,7 @@ Exit status:
|
|
|
27
31
|
0 Checks completed; ordinary doctor warnings are advisory.
|
|
28
32
|
1 Diagnostic errors, failed or partial explicit worker qualification, or blocked recorded invocations.
|
|
29
33
|
2 Invalid usage.
|
|
34
|
+
--resources exits 1 when slots are zero.
|
|
30
35
|
--qualify uses the same exit status in text and JSON output.
|
|
31
36
|
`;
|
|
32
37
|
//# sourceMappingURL=doctor-help.js.map
|
|
@@ -19,7 +19,7 @@ import { statusHandler, wizardHandler, migrateWorkspaceHandler, rollbackWorkspac
|
|
|
19
19
|
import { prefillCardsHandler, contributeStartHandler, validateMetadataHandler, doctorHandler, contextFirewallHandler, updateHandler, utilityHandlers, } from './utilities.js';
|
|
20
20
|
import { skillLintHandler } from './skill-lint.js';
|
|
21
21
|
import { addAgentHandler, addCommandHandler, addSkillHandler, addBehaviorHandler, addTemplateHandler, scaffoldAddonHandler, scaffoldExtensionHandler, scaffoldFrameworkHandler, scaffoldingHandlers, } from './scaffolding.js';
|
|
22
|
-
import { behaviorHandler, daemonInitHandler, daemonHandlers, } from './daemon.js';
|
|
22
|
+
import { behaviorHandler, daemonHandler, daemonInitHandler, daemonHandlers, } from './daemon.js';
|
|
23
23
|
import { housekeeperHandler, housekeeperHandlers, } from './housekeeper.js';
|
|
24
24
|
import { ralphHandler, ralphStatusHandler, ralphAbortHandler, ralphResumeHandler, ralphAttachHandler, ralphExternalHandler, ralphMemoryHandler, ralphConfigHandler, ralphHandlers, } from './ralph.js';
|
|
25
25
|
import { mcpHandler, catalogHandler, listHandler, removeHandler, promoteHandler, newBundleHandler, quickrefHandler, newProjectHandler, installPluginHandler, uninstallPluginHandler, pluginStatusHandler, packagePluginHandler, packageAllPluginsHandler, indexHandler, corpusHandler, discoverHandler, showHandler, featuresHandler, skillsHandler, configHandler, opsHandler, storageHandler, activityLogHandler, kbHandler, memoryHandler, reflectionsHandler, provenanceHandler, researchStoreHandler, researchQueryHandler, chunkHandler, fanoutHandler, rlmPrepHandler, rlmSearchHandler, rlmStatusCliHandler, rlmCacheHandler, subcommandHandlers, } from './subcommands.js';
|
|
@@ -98,7 +98,7 @@ installPluginHandler, uninstallPluginHandler, pluginStatusHandler, packagePlugin
|
|
|
98
98
|
// Scaffolding
|
|
99
99
|
addAgentHandler, addCommandHandler, addSkillHandler, addBehaviorHandler, addTemplateHandler, scaffoldAddonHandler, scaffoldExtensionHandler, scaffoldFrameworkHandler,
|
|
100
100
|
// Daemon
|
|
101
|
-
behaviorHandler, daemonInitHandler, housekeeperHandler,
|
|
101
|
+
behaviorHandler, daemonHandler, daemonInitHandler, housekeeperHandler,
|
|
102
102
|
// Ralph
|
|
103
103
|
ralphHandler, ralphStatusHandler, ralphAbortHandler, ralphResumeHandler, ralphAttachHandler, ralphExternalHandler, ralphMemoryHandler, ralphConfigHandler,
|
|
104
104
|
// Mission Control
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Sample the project and actual CLI request filesystems before rendering a worker.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readLiveHostResources } from '../../config/host-resource-runtime.mjs';
|
|
4
|
+
import { parseWorkerCommandArgs } from '../../serve/worker-command-request.js';
|
|
5
|
+
export function sampleWorkerHostResources(ctx, readers) {
|
|
6
|
+
const request = ctx.args[0] === 'resolve' ? parseWorkerCommandArgs(ctx.args.slice(1)) : undefined;
|
|
7
|
+
const paths = request ? [ctx.cwd, request.workdir, path.dirname(request.final_output)] : [ctx.cwd];
|
|
8
|
+
return readLiveHostResources({ ...readers, paths });
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=models-resource-sample.js.map
|
|
@@ -2,6 +2,7 @@ import { MODELS_HELP } from './models-help.js';
|
|
|
2
2
|
import { updateJson } from '../../models/config-writer.js';
|
|
3
3
|
import { atomicConfigWrite as atomicWrite } from '../../config/worker-write.js';
|
|
4
4
|
import { handleWorkerAdoptionArgs } from '../../config/worker-adoption-cli.js';
|
|
5
|
+
import { sampleWorkerHostResources } from './models-resource-sample.js';
|
|
5
6
|
import { resolveParallelism } from '../../config/aiwg-config.js';
|
|
6
7
|
/**
|
|
7
8
|
* Safe model-policy audit, resolution, and mutation commands.
|
|
@@ -33,7 +34,7 @@ function approvalFacts(row) {
|
|
|
33
34
|
* without shelling out to the CLI. No new loader is introduced; this is the
|
|
34
35
|
* CLI's own existing default `ModelsWorkerServices.load`.
|
|
35
36
|
*/
|
|
36
|
-
export async function loadWorkerInputs(ctx) {
|
|
37
|
+
export async function loadWorkerInputs(ctx, resourceReaders) {
|
|
37
38
|
const config = await readAiwgConfig(ctx.cwd) ?? emptyConfig();
|
|
38
39
|
const loader = new ConfigLoader(ctx.cwd);
|
|
39
40
|
const models = await loader.load(config.parallelism);
|
|
@@ -116,7 +117,7 @@ export async function loadWorkerInputs(ctx) {
|
|
|
116
117
|
}) };
|
|
117
118
|
}
|
|
118
119
|
return { snapshot: { config, models, modelDigests: loader.getInputDigests(), catalog,
|
|
119
|
-
registry: qualifiedRegistry, installations }, drivers };
|
|
120
|
+
registry: qualifiedRegistry, installations, hostResources: sampleWorkerHostResources(ctx, { ...resourceReaders, groupNames: Object.keys(config.parallelism?.groups ?? {}) }) }, drivers };
|
|
120
121
|
}
|
|
121
122
|
async function resolveDirect(ctx, services) {
|
|
122
123
|
let shell = false;
|