@aiwg/cli 2026.10.15 → 2026.10.18
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/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 +8 -3
- package/dist/src/artifacts/corpus-tools/discovery-log.js +26 -24
- package/dist/src/artifacts/corpus-tools/expand-cli.js +3 -2
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +4 -1
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +17 -1
- package/dist/src/artifacts/corpus-tools/expand.js +16 -17
- 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 +11 -3
- package/dist/src/artifacts/corpus-tools/resolve.js +42 -11
- 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/artifacts/query-engine-corpus.js +217 -0
- package/dist/src/artifacts/query-engine-discover-output.js +229 -0
- package/dist/src/artifacts/query-engine-discover.js +285 -0
- package/dist/src/artifacts/query-engine-entries.js +188 -0
- package/dist/src/artifacts/query-engine-index.js +249 -0
- package/dist/src/artifacts/query-engine-matching.js +143 -0
- package/dist/src/artifacts/query-engine-options.js +2 -0
- package/dist/src/artifacts/query-engine-rules.js +202 -0
- package/dist/src/artifacts/query-engine-scoring.js +436 -0
- package/dist/src/artifacts/query-engine-show-card.js +194 -0
- package/dist/src/artifacts/query-engine-show-load.js +211 -0
- package/dist/src/artifacts/query-engine-show.js +300 -0
- package/dist/src/artifacts/query-engine.js +7 -2576
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +10 -5
- package/dist/src/cli/handlers/doctor-help.js +4 -1
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/mc-agents.js +111 -0
- package/dist/src/cli/handlers/mc-args.js +54 -0
- package/dist/src/cli/handlers/mc-control.js +227 -0
- package/dist/src/cli/handlers/mc-dispatch.js +203 -0
- package/dist/src/cli/handlers/mc-help.js +171 -0
- package/dist/src/cli/handlers/mc-run.js +343 -0
- package/dist/src/cli/handlers/mc-session.js +138 -0
- package/dist/src/cli/handlers/mc-status.js +258 -0
- package/dist/src/cli/handlers/mc-summary.js +43 -0
- package/dist/src/cli/handlers/mc-types.js +3 -0
- package/dist/src/cli/handlers/mc-worker.js +205 -0
- package/dist/src/cli/handlers/mc.js +12 -1665
- package/dist/src/cli/handlers/models-refusal.js +13 -0
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +5 -3
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/remove-bundled.js +133 -0
- package/dist/src/cli/handlers/remove-options.js +31 -0
- package/dist/src/cli/handlers/remove-user.js +174 -0
- package/dist/src/cli/handlers/remove.js +201 -0
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
- package/dist/src/cli/handlers/subcommands-list.js +250 -0
- package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
- package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
- package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
- package/dist/src/cli/handlers/subcommands-services.js +66 -0
- package/dist/src/cli/handlers/subcommands-storage.js +259 -0
- package/dist/src/cli/handlers/subcommands.js +18 -1976
- 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 -560
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/scope-resolver.js +1 -142
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/cli/user-scope-mirror.js +173 -0
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-host-thresholds.js +2 -0
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +21 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +24 -0
- package/dist/src/config/host-resource-report.mjs +110 -0
- package/dist/src/config/host-resource-runtime.d.mts +37 -0
- package/dist/src/config/host-resource-runtime.mjs +296 -0
- package/dist/src/config/installed-selection.js +22 -0
- 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/ensemble-study/artifacts.js +7 -0
- package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
- package/dist/src/decision/ensemble-study/gates.js +78 -0
- package/dist/src/decision/ensemble-study/protocol.js +18 -21
- package/dist/src/decision/ensemble-study/score.js +3 -2
- package/dist/src/decision/ensemble-study/statistics.js +7 -26
- 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 +8 -1
- package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
- package/dist/src/decision/sensitivity/comparative.js +18 -41
- 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 +133 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/gates/evaluate.js +2 -358
- package/dist/src/gates/heldout.js +17 -7
- package/dist/src/gates/observations.js +363 -0
- package/dist/src/gates/pack-composition.js +270 -0
- package/dist/src/gates/pack-tightening.js +197 -0
- package/dist/src/gates/pack-validation.js +262 -0
- package/dist/src/gates/registry-error.js +5 -0
- package/dist/src/gates/registry.js +13 -685
- 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/mcp/json-document.mjs +29 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -28
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/mission-protocol/worker-review-gate.js +7 -0
- 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/plugin/command-ownership.js +34 -0
- package/dist/src/plugin/skill-command-frontmatter.js +197 -0
- package/dist/src/plugin/skill-command-translator.js +6 -232
- 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/context-output-ownership.js +26 -0
- package/dist/src/providers/deployment-ownership.d.mts +19 -0
- package/dist/src/providers/deployment-ownership.mjs +226 -0
- package/dist/src/providers/deployment-removal.js +200 -0
- 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/providers/removal-transaction.js +86 -0
- package/dist/src/providers/settings-document.d.mts +3 -0
- package/dist/src/providers/settings-document.mjs +47 -0
- package/dist/src/providers/settings-removal.js +190 -0
- package/dist/src/providers/skill-ownership.d.mts +19 -2
- package/dist/src/providers/skill-ownership.mjs +12 -4
- package/dist/src/providers/transformation-receipt-integration.js +15 -271
- package/dist/src/providers/transformation-receipt-outputs.js +99 -0
- package/dist/src/providers/transformation-receipt-source.js +194 -0
- package/dist/src/research/clients/arxiv.js +4 -30
- package/dist/src/research/clients/base.js +48 -22
- package/dist/src/research/identity.js +42 -4
- 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 +105 -24
- 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/activation.mjs +15 -6
- package/dist/src/rules/core-startup.mjs +2 -2
- package/dist/src/serve/mission-conductor.js +52 -4
- package/dist/src/serve/mission-summary.js +56 -0
- 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/aiwg-md.js +39 -46
- 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/context-file-safety.js +3 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +10 -11
- package/dist/src/smiths/context-pipeline/managed-hook.js +1 -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/dist/src/smiths/hook-bridge/index.js +9 -0
- package/package.json +13 -1
- package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +24 -675
- package/tools/agents/deploy-command-mirrors.mjs +229 -0
- package/tools/agents/deploy-options.mjs +258 -0
- package/tools/agents/deploy-support.mjs +165 -0
- package/tools/agents/providers/base-addon-discovery.mjs +139 -0
- package/tools/agents/providers/base-behaviors.mjs +168 -0
- package/tools/agents/providers/base-context.mjs +205 -0
- package/tools/agents/providers/base-contract.mjs +116 -0
- package/tools/agents/providers/base-files.mjs +252 -0
- package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
- package/tools/agents/providers/base-framework-discovery.mjs +309 -0
- package/tools/agents/providers/base-frontmatter.mjs +196 -0
- package/tools/agents/providers/base-inventory.mjs +269 -0
- package/tools/agents/providers/base-kernel-skills.mjs +354 -0
- package/tools/agents/providers/base-migrations.mjs +258 -0
- package/tools/agents/providers/base-models-platforms.mjs +273 -0
- package/tools/agents/providers/base-rule-index.mjs +450 -0
- package/tools/agents/providers/base-runtime.mjs +60 -0
- package/tools/agents/providers/base-skill-copy.mjs +273 -0
- package/tools/agents/providers/base.mjs +16 -3364
- package/tools/agents/providers/claude-post-deploy.mjs +20 -1
- package/tools/agents/providers/context-write.mjs +4 -0
- package/tools/agents/providers/hermes-startup.mjs +0 -5
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/pi.mjs +3 -1
- package/tools/agents/providers/rule-delivery-surface.mjs +359 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1144
- package/tools/agents/providers/rule-deployment-commit.mjs +148 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +461 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/agents/providers/rule-projection.mjs +3 -0
- 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/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 +7 -4
- 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-termination.mjs +15 -8
- 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
- package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
package/dist/src/lint/runner.js
CHANGED
|
@@ -14,35 +14,9 @@ import fsp from 'fs/promises';
|
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { glob } from 'glob';
|
|
16
16
|
import { minimatch } from 'minimatch';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Returns key-value pairs from the --- delimited block
|
|
21
|
-
*/
|
|
22
|
-
function parseFrontmatter(content) {
|
|
23
|
-
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
24
|
-
if (!match)
|
|
25
|
-
return {};
|
|
26
|
-
try {
|
|
27
|
-
const parsed = parse(match[1]);
|
|
28
|
-
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
29
|
-
? parsed
|
|
30
|
-
: {};
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
// Invalid YAML cannot supply required metadata.
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function isPresent(value) {
|
|
38
|
-
if (value == null)
|
|
39
|
-
return false;
|
|
40
|
-
if (typeof value === 'string')
|
|
41
|
-
return value.trim().length > 0;
|
|
42
|
-
if (Array.isArray(value))
|
|
43
|
-
return value.length > 0;
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
17
|
+
import { parseFrontmatter, runCheck } from './checks.js';
|
|
18
|
+
import { buildReferenceIndex } from './reference-resolution.js';
|
|
19
|
+
export { DEFAULT_ABSENCE_MARKERS, DEFAULT_UNCERTAINTY_PATTERNS, DEFAULT_VERIFICATION_TARGETS, DEFAULT_OBSTACLE_PATTERNS, DATED_OUTCOME_PATTERN, CLOSURE_OUTCOME_PATTERN } from './check-patterns.js';
|
|
46
20
|
/** Resolve project-relative metadata from the nearest repository/workspace marker. */
|
|
47
21
|
function findProjectRoot(targetDir) {
|
|
48
22
|
let dir = path.resolve(targetDir);
|
|
@@ -56,442 +30,6 @@ function findProjectRoot(targetDir) {
|
|
|
56
30
|
dir = parent;
|
|
57
31
|
}
|
|
58
32
|
}
|
|
59
|
-
const DEFAULT_REFERENCE_PATTERN = '\\bREF-\\d{3,}\\b';
|
|
60
|
-
/**
|
|
61
|
-
* Phrases that mark an identifier as deliberately absent (#2555). A mention
|
|
62
|
-
* next to one of these documents a gap rather than pointing at a document, so
|
|
63
|
-
* it is not an unresolved reference.
|
|
64
|
-
*/
|
|
65
|
-
export const DEFAULT_ABSENCE_MARKERS = [
|
|
66
|
-
'\\bunallocated\\b',
|
|
67
|
-
'\\bnot in corpus\\b',
|
|
68
|
-
'\\bskipped\\b',
|
|
69
|
-
'\\bretired\\b',
|
|
70
|
-
'\\bwithdrawn\\b',
|
|
71
|
-
'\\bdeliberately (?:absent|unallocated|skipped)\\b',
|
|
72
|
-
'\\bnever (?:allocated|assigned)\\b',
|
|
73
|
-
'\\bdeduplicat',
|
|
74
|
-
];
|
|
75
|
-
// Deliberately NOT markers: "does not exist", "missing", "no longer exists".
|
|
76
|
-
// Those are how a broken reference is described, not how a corpus records an
|
|
77
|
-
// intentional gap, and treating them as markers would suppress the finding this
|
|
78
|
-
// check exists for.
|
|
79
|
-
/**
|
|
80
|
-
* Verification targets — things the inducting agent could have checked.
|
|
81
|
-
*
|
|
82
|
-
* Requiring one of these is what separates "the agent skipped a cheap check"
|
|
83
|
-
* from "the paper's own claim is unverified". Only the first is a provenance
|
|
84
|
-
* gap; the second is legitimate analysis, and #2523 explicitly does not ask
|
|
85
|
-
* agents to stop declaring limitations. Validated against a 2,544-reference
|
|
86
|
-
* corpus, where grammar-only matching made ~45% of hits paper-claim prose
|
|
87
|
-
* ("scaling behavior above 7B is unverified", "Not confirmed (34% vs 51%)").
|
|
88
|
-
*/
|
|
89
|
-
/**
|
|
90
|
-
* Split a markdown line into clauses.
|
|
91
|
-
*
|
|
92
|
-
* Corpus prose keeps whole paragraphs, bullet bodies and changelog table rows on
|
|
93
|
-
* a single line, so "same line" is far too coarse a scope for relating an
|
|
94
|
-
* unperformed action to its target. Sentence and cell boundaries are the unit
|
|
95
|
-
* that actually corresponds to one statement.
|
|
96
|
-
*/
|
|
97
|
-
function splitClauses(line) {
|
|
98
|
-
return line
|
|
99
|
-
.split(/(?<=[.;:!?])\s+|\s+\u2014\s+|\s+--\s+|\|/g)
|
|
100
|
-
.map((c) => c.trim())
|
|
101
|
-
.filter(Boolean);
|
|
102
|
-
}
|
|
103
|
-
export const DEFAULT_VERIFICATION_TARGETS = [
|
|
104
|
-
'openreview',
|
|
105
|
-
'(?:acl )?anthology',
|
|
106
|
-
'proceedings',
|
|
107
|
-
'camera[- ]ready',
|
|
108
|
-
'published version',
|
|
109
|
-
'\\bPMLR\\b',
|
|
110
|
-
'\\bDBLP\\b',
|
|
111
|
-
'\\bOpenAlex\\b',
|
|
112
|
-
'semantic scholar',
|
|
113
|
-
'\\bpubpeer\\b',
|
|
114
|
-
'\\bunpaywall\\b',
|
|
115
|
-
'retraction|correction notice|expression of concern',
|
|
116
|
-
'citation (?:census|count)',
|
|
117
|
-
'influential citation',
|
|
118
|
-
'\\bPDF\\b',
|
|
119
|
-
'full[- ]text',
|
|
120
|
-
'\\be-?print\\b',
|
|
121
|
-
'(?:code|project|dataset|repository|repo)\\s+(?:page|url|link|release|availability)',
|
|
122
|
-
'\\bvenue\\b',
|
|
123
|
-
'\\bacceptance\\b',
|
|
124
|
-
'source[_ ]type',
|
|
125
|
-
];
|
|
126
|
-
/**
|
|
127
|
-
* Phrases that assert a check was not performed. Drawn from real induction
|
|
128
|
-
* output — each of these has appeared in a corpus reference doc (#2523).
|
|
129
|
-
* Only counted when a verification target appears on the same line.
|
|
130
|
-
*/
|
|
131
|
-
export const DEFAULT_UNCERTAINTY_PATTERNS = [
|
|
132
|
-
'(?:was|were|is|are) not (?:retrieved|run|performed|attempted|fetched|queried|checked|acquired|probed|verified|confirmed)',
|
|
133
|
-
'not (?:retrieved|run|performed|attempted|fetched|queried|checked|acquired|probed|verified|confirmed)\\b',
|
|
134
|
-
// Requires the action to be stated as unperformed. Without the trailing verb
|
|
135
|
-
// this matched bare "no search" in unrelated prose and scope statements like
|
|
136
|
-
// "no exhaustive census is claimed", neither of which is a skipped check.
|
|
137
|
-
'no (?:\\w+[ -]){0,4}(?:quer(?:y|ies)|search|census|fetch|check|lookup|probe)(?:es|s)?\\s+(?:was |were )?(?:performed|run|attempted|made|conducted|executed)',
|
|
138
|
-
'\\b(?:is|remains) unverified\\b',
|
|
139
|
-
'\\bunconfirmed\\b',
|
|
140
|
-
'rests on .{0,60} rather than an independent',
|
|
141
|
-
];
|
|
142
|
-
/**
|
|
143
|
-
* A dated outcome closes an uncertainty (#2523's "records an outcome with a
|
|
144
|
-
* date"). The vocabulary is deliberately wider than a verb+date pair: the
|
|
145
|
-
* retraction convention recommended alongside this rule writes
|
|
146
|
-
* `~~<limitation>~~ **Done YYYY-MM-DD (<what closed it>).**`, which no
|
|
147
|
-
* verb+date pattern matches, so a correctly dated retraction was rejected for
|
|
148
|
-
* its shape (#2556).
|
|
149
|
-
*/
|
|
150
|
-
export const DATED_OUTCOME_PATTERN = '(?:\\b(?:done|resolved|completed|closed|addressed|fixed|verified|retrieved|archived|queried|fetched|checked|probed|confirmed)\\b[^\\n]{0,60}?\\d{4}-\\d{2}-\\d{2}|\\d{4}-\\d{2}-\\d{2}[^\\n]{0,30}?\\b(?:done|resolved|completed|closed|addressed|fixed)\\b)';
|
|
151
|
-
/**
|
|
152
|
-
* The closure half of {@link DATED_OUTCOME_PATTERN}. Only explicit closure
|
|
153
|
-
* verbs count outside a struck span: a date sitting anywhere near an action
|
|
154
|
-
* verb ("...was not retrieved at induction. Induction ran 2026-09-01.") is not
|
|
155
|
-
* an outcome, and treating it as one would discharge the very statements this
|
|
156
|
-
* rule exists to catch.
|
|
157
|
-
*/
|
|
158
|
-
export const CLOSURE_OUTCOME_PATTERN = '(?:\\b(?:done|resolved|completed|closed|addressed|fixed)\\b[^\\n]{0,60}?\\d{4}-\\d{2}-\\d{2}|\\d{4}-\\d{2}-\\d{2}[^\\n]{0,30}?\\b(?:done|resolved|completed|closed|addressed|fixed)\\b)';
|
|
159
|
-
/**
|
|
160
|
-
* Spans struck through with `~~…~~` are, by the markup's own meaning, no longer
|
|
161
|
-
* asserted. When a dated outcome follows the span on the same line, the pair is
|
|
162
|
-
* a completed retraction however long the struck text is — the length of the
|
|
163
|
-
* struck span was the hidden variable behind #2556.
|
|
164
|
-
*/
|
|
165
|
-
function retractedWithDatedOutcome(line) {
|
|
166
|
-
const dated = new RegExp(DATED_OUTCOME_PATTERN, 'i');
|
|
167
|
-
const strikethrough = /~~([\s\S]*?)~~/g;
|
|
168
|
-
let match;
|
|
169
|
-
while ((match = strikethrough.exec(line)) !== null) {
|
|
170
|
-
if (dated.test(line.slice(match.index + match[0].length)))
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
/** Character offsets of every `~~…~~` span on a line. */
|
|
176
|
-
function strikethroughSpans(line) {
|
|
177
|
-
const spans = [];
|
|
178
|
-
const strikethrough = /~~([\s\S]*?)~~/g;
|
|
179
|
-
let match;
|
|
180
|
-
while ((match = strikethrough.exec(line)) !== null) {
|
|
181
|
-
spans.push({ start: match.index, end: match.index + match[0].length });
|
|
182
|
-
}
|
|
183
|
-
return spans;
|
|
184
|
-
}
|
|
185
|
-
export const DEFAULT_OBSTACLE_PATTERNS = [
|
|
186
|
-
'\\bHTTP\\s?[45]\\d{2}\\b',
|
|
187
|
-
'\\b(?:401|403|404|429|451|503)\\b',
|
|
188
|
-
'paywall',
|
|
189
|
-
'closed[- ]access',
|
|
190
|
-
'requires? (?:a )?(?:credential|token|API key|subscription|login|account)',
|
|
191
|
-
'\\b(?:HF_TOKEN|API[_ ]KEY)\\b',
|
|
192
|
-
'rate[- ]limit',
|
|
193
|
-
'anti[- ]bot',
|
|
194
|
-
'cloudflare',
|
|
195
|
-
'captcha',
|
|
196
|
-
'endpoint unknown',
|
|
197
|
-
'no (?:known )?endpoint',
|
|
198
|
-
// Obstacle vocabulary observed in a real corpus: these are named obstacles,
|
|
199
|
-
// so the statement is already a real outcome rather than a silent skip.
|
|
200
|
-
'proof[- ]of[- ]work',
|
|
201
|
-
'challenge (?:artifact|page|response)',
|
|
202
|
-
'returned challenge',
|
|
203
|
-
'\\bgated\\b',
|
|
204
|
-
'did not render',
|
|
205
|
-
'green OA',
|
|
206
|
-
// Explicit scope declarations: saying what is deliberately not claimed is an
|
|
207
|
-
// outcome, unlike omitting the check and not saying so.
|
|
208
|
-
'is not (?:claimed|asserted)',
|
|
209
|
-
'NOT (?:recorded|asserted) as',
|
|
210
|
-
'evidence boundary',
|
|
211
|
-
'completion_evidence',
|
|
212
|
-
'status:\\s*(?:incomplete|blocked)',
|
|
213
|
-
'\\b(?:queried|fetched|checked|probed|confirmed|resolved)\\s+(?:on\\s+)?\\d{4}-\\d{2}-\\d{2}',
|
|
214
|
-
'\\bdeferred\\b.{0,40}\\b(?:because|since|due to)\\b',
|
|
215
|
-
// An explicit dated closure ("**Done 2026-09-12 (post-induction audit).**"),
|
|
216
|
-
// which the verb+date pattern above does not match (#2556).
|
|
217
|
-
CLOSURE_OUTCOME_PATTERN,
|
|
218
|
-
];
|
|
219
|
-
/**
|
|
220
|
-
* Build a target-wide artifact ID index once per lint run.
|
|
221
|
-
*
|
|
222
|
-
* Reference documents may use either an exact filename (`REF-001.md`) or the
|
|
223
|
-
* canonical slugged form (`REF-001-some-title.md`). Indexing the ID prefix also
|
|
224
|
-
* makes resolution independent of a particular corpus directory layout.
|
|
225
|
-
*/
|
|
226
|
-
function buildReferenceIndex(allFiles) {
|
|
227
|
-
const references = new Set();
|
|
228
|
-
for (const file of allFiles) {
|
|
229
|
-
if (path.extname(file).toLowerCase() !== '.md')
|
|
230
|
-
continue;
|
|
231
|
-
const basename = path.basename(file, '.md');
|
|
232
|
-
if (/^REF-\d+-(?:citations|radar)$/.test(basename))
|
|
233
|
-
continue;
|
|
234
|
-
references.add(basename);
|
|
235
|
-
const artifactId = basename.match(/^(.+?-\d+)(?:-|$)/);
|
|
236
|
-
if (artifactId)
|
|
237
|
-
references.add(artifactId[1]);
|
|
238
|
-
}
|
|
239
|
-
return references;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Preserve support for references stored outside the lint target when a rule
|
|
243
|
-
* explicitly supplies basePath. Accept both exact and slugged filenames.
|
|
244
|
-
*/
|
|
245
|
-
function resolvesFromBasePath(refId, targetDir, basePath, projectRoot) {
|
|
246
|
-
const candidateDirs = new Set([
|
|
247
|
-
path.resolve(projectRoot, basePath),
|
|
248
|
-
path.resolve(targetDir, basePath),
|
|
249
|
-
path.resolve(process.cwd(), basePath),
|
|
250
|
-
]);
|
|
251
|
-
for (const dir of candidateDirs) {
|
|
252
|
-
try {
|
|
253
|
-
if (fs.existsSync(path.join(dir, `${refId}.md`)))
|
|
254
|
-
return true;
|
|
255
|
-
if (fs.readdirSync(dir).some(file => file.startsWith(`${refId}-`) && file.endsWith('.md'))) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
catch {
|
|
260
|
-
// Missing or unreadable candidate directories do not resolve the ID.
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Run a single check against a file's content and frontmatter
|
|
267
|
-
*/
|
|
268
|
-
function runCheck(check, content, frontmatter, filePath, targetDir, allFiles, referenceIndex, projectRoot) {
|
|
269
|
-
const diagnostics = [];
|
|
270
|
-
switch (check.type) {
|
|
271
|
-
case 'frontmatter-required': {
|
|
272
|
-
if (!check.fields)
|
|
273
|
-
break;
|
|
274
|
-
for (const field of check.fields) {
|
|
275
|
-
if (!isPresent(frontmatter[field])) {
|
|
276
|
-
diagnostics.push({
|
|
277
|
-
ruleId: '',
|
|
278
|
-
ruleName: '',
|
|
279
|
-
severity: 'error',
|
|
280
|
-
file: filePath,
|
|
281
|
-
message: `Missing required frontmatter field: ${field}`,
|
|
282
|
-
fix: `Add '${field}:' to the YAML frontmatter block`,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case 'frontmatter-format': {
|
|
289
|
-
if (!check.field || !check.pattern)
|
|
290
|
-
break;
|
|
291
|
-
const value = frontmatter[check.field];
|
|
292
|
-
if (isPresent(value) && typeof value !== 'object' && !new RegExp(check.pattern).test(String(value))) {
|
|
293
|
-
diagnostics.push({
|
|
294
|
-
ruleId: '',
|
|
295
|
-
ruleName: '',
|
|
296
|
-
severity: 'warn',
|
|
297
|
-
file: filePath,
|
|
298
|
-
message: `Frontmatter field '${check.field}' value '${value}' does not match pattern: ${check.pattern}`,
|
|
299
|
-
fix: `Update '${check.field}' to match the expected format`,
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
case 'reference-resolves': {
|
|
305
|
-
const refPattern = check.referencePattern || DEFAULT_REFERENCE_PATTERN;
|
|
306
|
-
const regex = new RegExp(refPattern, 'g');
|
|
307
|
-
const lines = content.split('\n');
|
|
308
|
-
const absence = (check.absenceMarkers ?? DEFAULT_ABSENCE_MARKERS).map((p) => new RegExp(p, 'i'));
|
|
309
|
-
for (let i = 0; i < lines.length; i++) {
|
|
310
|
-
let match;
|
|
311
|
-
while ((match = regex.exec(lines[i])) !== null) {
|
|
312
|
-
const refId = match[0];
|
|
313
|
-
const basePaths = check.basePath
|
|
314
|
-
? [check.basePath]
|
|
315
|
-
: ['.aiwg/research/findings', 'findings', 'documentation/references', '.'];
|
|
316
|
-
// A corpus documents its deliberate gaps ("REF-2464 remains
|
|
317
|
-
// unallocated after deduplication"). Reading that sentence as a
|
|
318
|
-
// dangling reference left only two ways to silence an error: delete
|
|
319
|
-
// accurate documentation, or allocate a REF that is deliberately
|
|
320
|
-
// absent (#2555).
|
|
321
|
-
if (absence.some((re) => re.test(lines[i])))
|
|
322
|
-
continue;
|
|
323
|
-
if (!referenceIndex.has(refId) && !basePaths.some(basePath => resolvesFromBasePath(refId, targetDir, basePath, projectRoot))) {
|
|
324
|
-
diagnostics.push({
|
|
325
|
-
ruleId: '',
|
|
326
|
-
ruleName: '',
|
|
327
|
-
severity: 'error',
|
|
328
|
-
file: filePath,
|
|
329
|
-
message: `Reference '${refId}' does not resolve to an existing file`,
|
|
330
|
-
line: i + 1,
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
case 'unregistered-uncertainty': {
|
|
338
|
-
// An uncertainty written only into prose is invisible to the verification
|
|
339
|
-
// contract: it was never a declared check, so it never surfaces as
|
|
340
|
-
// `incomplete` and the "never report skipped verification as success" rule
|
|
341
|
-
// is never violated. Flag the bare form; accept it once a specific
|
|
342
|
-
// obstacle is named or an outcome is recorded (#2523).
|
|
343
|
-
const uncertainty = (check.uncertaintyPatterns ?? DEFAULT_UNCERTAINTY_PATTERNS)
|
|
344
|
-
.map((p) => new RegExp(p, 'i'));
|
|
345
|
-
const targets = (check.verificationTargets ?? DEFAULT_VERIFICATION_TARGETS)
|
|
346
|
-
.map((p) => new RegExp(p, 'i'));
|
|
347
|
-
const obstacle = (check.obstaclePatterns ?? DEFAULT_OBSTACLE_PATTERNS)
|
|
348
|
-
.map((p) => new RegExp(p, 'i'));
|
|
349
|
-
const within = check.obstacleWithinLines ?? 2;
|
|
350
|
-
const lines = content.split('\n');
|
|
351
|
-
for (let i = 0; i < lines.length; i++) {
|
|
352
|
-
// Both conditions must hold in the SAME CLAUSE: an unperformed action
|
|
353
|
-
// AND something the agent could have acted on. Without the target, the
|
|
354
|
-
// match is as likely to be the paper's own limitation, which must stay
|
|
355
|
-
// untouched. Without clause scoping, a long markdown line relates two
|
|
356
|
-
// unrelated clauses — real corpus prose puts whole paragraphs and
|
|
357
|
-
// changelog tables on one line, which produced most false positives.
|
|
358
|
-
const clause = splitClauses(lines[i]).find((c) => uncertainty.some((re) => re.test(c)) && targets.some((re) => re.test(c)));
|
|
359
|
-
if (!clause)
|
|
360
|
-
continue;
|
|
361
|
-
// A struck span followed by a dated outcome is a completed retraction,
|
|
362
|
-
// whatever its length. Clause scoping otherwise ends the window before
|
|
363
|
-
// the `**Done <date>**` that closes it, so the recommended convention
|
|
364
|
-
// failed for two-sentence struck text and passed for one (#2556).
|
|
365
|
-
const clauseAt = lines[i].indexOf(clause);
|
|
366
|
-
const struck = clauseAt >= 0 && strikethroughSpans(lines[i])
|
|
367
|
-
.some((span) => clauseAt >= span.start && clauseAt < span.end);
|
|
368
|
-
if (struck && retractedWithDatedOutcome(lines[i]))
|
|
369
|
-
continue;
|
|
370
|
-
// Look in the matching line and the following `within` lines: the
|
|
371
|
-
// obstacle normally sits in the same sentence or the next one.
|
|
372
|
-
const window = lines.slice(i, i + within + 1).join(' ');
|
|
373
|
-
if (obstacle.some((re) => re.test(window)))
|
|
374
|
-
continue;
|
|
375
|
-
diagnostics.push({
|
|
376
|
-
ruleId: '',
|
|
377
|
-
ruleName: '',
|
|
378
|
-
// Left unset so the rule's declared severity applies (see runRule).
|
|
379
|
-
// This is a prose heuristic, so the shipped rule declares `warn`; an
|
|
380
|
-
// operator can raise it to error once a corpus is clean.
|
|
381
|
-
severity: undefined,
|
|
382
|
-
file: filePath,
|
|
383
|
-
line: i + 1,
|
|
384
|
-
message: `Uncertainty stated without a named obstacle or recorded outcome: ${clause.trim().slice(0, 160)}`,
|
|
385
|
-
fix: 'Resolve it if it costs about one request against a known endpoint, or name the specific obstacle (HTTP status, credential required, rate limited, paywalled) so it lands as incomplete/blocked rather than narrative. If the check has since been done, retract the statement with the dated form — `~~<original limitation>~~ **Done YYYY-MM-DD (<what closed it>).** <evidence>` — which closes it whatever the length of the struck text.',
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
case 'pattern-match': {
|
|
391
|
-
if (!check.pattern)
|
|
392
|
-
break;
|
|
393
|
-
const regex = new RegExp(check.pattern);
|
|
394
|
-
if (!regex.test(content)) {
|
|
395
|
-
diagnostics.push({
|
|
396
|
-
ruleId: '',
|
|
397
|
-
ruleName: '',
|
|
398
|
-
severity: 'warn',
|
|
399
|
-
file: filePath,
|
|
400
|
-
message: `File content does not match expected pattern: ${check.pattern}`,
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
405
|
-
case 'file-exists': {
|
|
406
|
-
if (!check.field)
|
|
407
|
-
break;
|
|
408
|
-
const refPath = frontmatter[check.field];
|
|
409
|
-
if (isPresent(refPath)) {
|
|
410
|
-
// Project-root-relative is canonical (#3145); target-relative paths
|
|
411
|
-
// written for the legacy layout keep resolving.
|
|
412
|
-
const found = typeof refPath === 'string' &&
|
|
413
|
-
[projectRoot, targetDir].some(base => fs.existsSync(path.resolve(base, refPath)));
|
|
414
|
-
if (!found) {
|
|
415
|
-
diagnostics.push({
|
|
416
|
-
ruleId: '',
|
|
417
|
-
ruleName: '',
|
|
418
|
-
severity: 'error',
|
|
419
|
-
file: filePath,
|
|
420
|
-
message: `Referenced file '${refPath}' (from field '${check.field}') does not exist`,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
case 'id-unique': {
|
|
427
|
-
// Handled at ruleset level in runRule
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
case 'id-format': {
|
|
431
|
-
if (!check.pattern)
|
|
432
|
-
break;
|
|
433
|
-
const basename = path.basename(filePath, '.md');
|
|
434
|
-
const match = basename.match(new RegExp(check.pattern));
|
|
435
|
-
if (!match) {
|
|
436
|
-
diagnostics.push({
|
|
437
|
-
ruleId: '',
|
|
438
|
-
ruleName: '',
|
|
439
|
-
severity: 'warn',
|
|
440
|
-
file: filePath,
|
|
441
|
-
message: `File name '${basename}' does not match expected format: ${check.pattern}`,
|
|
442
|
-
fix: `Rename to match the pattern ${check.pattern}`,
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
else if (check.field && isPresent(frontmatter[check.field])) {
|
|
446
|
-
const identifier = match[1] ?? match[0];
|
|
447
|
-
const value = frontmatter[check.field];
|
|
448
|
-
if (value !== identifier) {
|
|
449
|
-
diagnostics.push({
|
|
450
|
-
ruleId: '',
|
|
451
|
-
ruleName: '',
|
|
452
|
-
severity: 'warn',
|
|
453
|
-
file: filePath,
|
|
454
|
-
message: `File identifier '${identifier}' does not match frontmatter field '${check.field}': ${String(value)}`,
|
|
455
|
-
fix: `Make the filename identifier and '${check.field}' field agree`,
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
case 'cross-ref-bidirectional': {
|
|
462
|
-
const refPattern = check.referencePattern || DEFAULT_REFERENCE_PATTERN;
|
|
463
|
-
const regex = new RegExp(refPattern, 'g');
|
|
464
|
-
const currentBasename = path.basename(filePath, '.md');
|
|
465
|
-
const matches = content.match(regex) || [];
|
|
466
|
-
for (const ref of matches) {
|
|
467
|
-
if (ref === currentBasename)
|
|
468
|
-
continue;
|
|
469
|
-
// Find the referenced file
|
|
470
|
-
const refFile = allFiles.find(f => path.basename(f, '.md') === ref);
|
|
471
|
-
if (refFile) {
|
|
472
|
-
try {
|
|
473
|
-
const refContent = fs.readFileSync(path.resolve(targetDir, refFile), 'utf8');
|
|
474
|
-
if (!refContent.includes(currentBasename)) {
|
|
475
|
-
diagnostics.push({
|
|
476
|
-
ruleId: '',
|
|
477
|
-
ruleName: '',
|
|
478
|
-
severity: 'info',
|
|
479
|
-
file: filePath,
|
|
480
|
-
message: `References '${ref}' but '${ref}' does not reference back to '${currentBasename}'`,
|
|
481
|
-
fix: `Add a cross-reference to '${currentBasename}' in ${ref}.md`,
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
catch {
|
|
486
|
-
// Skip if can't read
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
break;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
return diagnostics;
|
|
494
|
-
}
|
|
495
33
|
/**
|
|
496
34
|
* Candidate paths a rule glob may be written against (#2555).
|
|
497
35
|
*
|
package/dist/src/mcp/helpers.mjs
CHANGED
|
@@ -354,7 +354,7 @@ export function mcpJson(data) {
|
|
|
354
354
|
/**
|
|
355
355
|
* Read AIWG CLI command registry to build the command-run allow-list.
|
|
356
356
|
*
|
|
357
|
-
* Lazily loaded from `src/extensions/commands/definitions.ts` — extracts
|
|
357
|
+
* Lazily loaded from `src/extensions/commands/definitions.ts` and its sibling command modules — extracts
|
|
358
358
|
* `id:` fields. Cached after first read.
|
|
359
359
|
*/
|
|
360
360
|
let _commandIds = null;
|
|
@@ -367,14 +367,24 @@ export async function loadCommandAllowList() {
|
|
|
367
367
|
path.resolve(process.cwd(), 'src/extensions/commands/definitions.ts'),
|
|
368
368
|
];
|
|
369
369
|
let text = '';
|
|
370
|
+
let found = null;
|
|
370
371
|
for (const c of candidates) {
|
|
371
372
|
try {
|
|
372
373
|
text = await fs.readFile(c, 'utf-8');
|
|
374
|
+
found = c;
|
|
373
375
|
break;
|
|
374
376
|
} catch {
|
|
375
377
|
// try next
|
|
376
378
|
}
|
|
377
379
|
}
|
|
380
|
+
if (text) {
|
|
381
|
+
// definitions.ts imports command groups from sibling modules (for example daemon.ts);
|
|
382
|
+
// read each one it imports so their ids are allowed too. A missing sibling is skipped.
|
|
383
|
+
const dir = path.dirname(found);
|
|
384
|
+
for (const [, name] of text.matchAll(/from '\.\/([A-Za-z0-9-]+)\.js'/g)) {
|
|
385
|
+
try { text += '\n' + await fs.readFile(path.join(dir, `${name}.ts`), 'utf-8'); } catch { /* skipped */ }
|
|
386
|
+
}
|
|
387
|
+
}
|
|
378
388
|
if (!text) {
|
|
379
389
|
// Installed packages need not contain TypeScript sources. Ask the CLI for
|
|
380
390
|
// its versioned canonical registry; human help is incomplete and contains examples.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Parse JSON settings with string-aware comment handling.
|
|
2
|
+
/**
|
|
3
|
+
* JSONC-tolerant parse. String-aware twin of `stripJsonComments` in
|
|
4
|
+
* tools/agents/providers/base.mjs: `//` in URLs and `/*` in glob
|
|
5
|
+
* matchers survive.
|
|
6
|
+
*/
|
|
7
|
+
export function parseJson(raw) {
|
|
8
|
+
const text = String(raw);
|
|
9
|
+
let out = '';
|
|
10
|
+
let i = 0;
|
|
11
|
+
while (i < text.length) {
|
|
12
|
+
const ch = text[i];
|
|
13
|
+
if (ch === '"') {
|
|
14
|
+
let j = i + 1;
|
|
15
|
+
while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1;
|
|
16
|
+
out += text.slice(i, j + 1);
|
|
17
|
+
i = j + 1;
|
|
18
|
+
} else if (ch === '/' && text[i + 1] === '/') {
|
|
19
|
+
while (i < text.length && text[i] !== '\n') i++;
|
|
20
|
+
} else if (ch === '/' && text[i + 1] === '*') {
|
|
21
|
+
const end = text.indexOf('*/', i + 2);
|
|
22
|
+
i = end === -1 ? text.length : end + 2;
|
|
23
|
+
} else {
|
|
24
|
+
out += ch;
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return JSON.parse(out);
|
|
29
|
+
}
|
|
@@ -13,34 +13,7 @@ const MUSE_HOOKS_SIDECAR_REL = join('.muse', '.aiwg-hooks.json');
|
|
|
13
13
|
|
|
14
14
|
const MUSE_VERSION_TIMEOUT_MS = 5_000;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
* JSONC-tolerant parse. String-aware twin of `stripJsonComments` in
|
|
18
|
-
* tools/agents/providers/base.mjs: `//` in URLs and `/*` in glob
|
|
19
|
-
* matchers survive.
|
|
20
|
-
*/
|
|
21
|
-
function parseJson(raw) {
|
|
22
|
-
const text = String(raw);
|
|
23
|
-
let out = '';
|
|
24
|
-
let i = 0;
|
|
25
|
-
while (i < text.length) {
|
|
26
|
-
const ch = text[i];
|
|
27
|
-
if (ch === '"') {
|
|
28
|
-
let j = i + 1;
|
|
29
|
-
while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1;
|
|
30
|
-
out += text.slice(i, j + 1);
|
|
31
|
-
i = j + 1;
|
|
32
|
-
} else if (ch === '/' && text[i + 1] === '/') {
|
|
33
|
-
while (i < text.length && text[i] !== '\n') i++;
|
|
34
|
-
} else if (ch === '/' && text[i + 1] === '*') {
|
|
35
|
-
const end = text.indexOf('*/', i + 2);
|
|
36
|
-
i = end === -1 ? text.length : end + 2;
|
|
37
|
-
} else {
|
|
38
|
-
out += ch;
|
|
39
|
-
i++;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return JSON.parse(out);
|
|
43
|
-
}
|
|
16
|
+
import { parseJson } from './json-document.mjs';
|
|
44
17
|
|
|
45
18
|
function deepEqual(a, b) {
|
|
46
19
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
|
-
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { lstat, mkdir, readFile, readdir, rename, rm, rmdir, writeFile } from 'node:fs/promises';
|
|
10
10
|
import { homedir } from 'node:os';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { boundedExecFileSync } from '../process/bounded-child-process.mjs';
|
|
@@ -159,9 +159,33 @@ export async function relocateProjectMemory(id, newMemoryRoot) {
|
|
|
159
159
|
throw new Error(`No project memory entry with id '${id}'`);
|
|
160
160
|
const oldRoot = entry.memoryRoot;
|
|
161
161
|
const nextRoot = expandUserPath(newMemoryRoot);
|
|
162
|
-
if (oldRoot !== nextRoot
|
|
163
|
-
await
|
|
164
|
-
|
|
162
|
+
if (oldRoot !== nextRoot) {
|
|
163
|
+
const destination = await lstat(nextRoot).catch(error => {
|
|
164
|
+
if (error.code === 'ENOENT')
|
|
165
|
+
return undefined;
|
|
166
|
+
throw error;
|
|
167
|
+
});
|
|
168
|
+
if (destination && (!destination.isDirectory() || (await readdir(nextRoot)).length > 0)) {
|
|
169
|
+
throw new Error(`Cannot relocate project memory from '${oldRoot}' to '${nextRoot}': destination is not empty`);
|
|
170
|
+
}
|
|
171
|
+
if (existsSync(oldRoot)) {
|
|
172
|
+
const createdParents = [];
|
|
173
|
+
try {
|
|
174
|
+
await createRelocationParents(path.dirname(nextRoot), createdParents);
|
|
175
|
+
// Rename can replace an empty directory; do not remove it before a move that may fail.
|
|
176
|
+
await rename(oldRoot, nextRoot);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
for (const parent of createdParents.reverse()) {
|
|
180
|
+
// Never remove contents another writer added, or mask the original move error.
|
|
181
|
+
await rmdir(parent).catch(() => { });
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
await ensureMemoryLayout(nextRoot);
|
|
188
|
+
}
|
|
165
189
|
}
|
|
166
190
|
else {
|
|
167
191
|
await ensureMemoryLayout(nextRoot);
|
|
@@ -171,6 +195,22 @@ export async function relocateProjectMemory(id, newMemoryRoot) {
|
|
|
171
195
|
await writeProjectMemoryManifest(manifest);
|
|
172
196
|
return entry;
|
|
173
197
|
}
|
|
198
|
+
// Track only mkdir calls we won, so rollback cannot claim another writer's parents.
|
|
199
|
+
async function createRelocationParents(directory, created) {
|
|
200
|
+
try {
|
|
201
|
+
await mkdir(directory);
|
|
202
|
+
created.push(directory);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
const code = error.code;
|
|
206
|
+
if (code === 'EEXIST')
|
|
207
|
+
return;
|
|
208
|
+
if (code !== 'ENOENT')
|
|
209
|
+
throw error;
|
|
210
|
+
await createRelocationParents(path.dirname(directory), created);
|
|
211
|
+
await createRelocationParents(directory, created);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
174
214
|
export async function removeProjectMemory(id, opts = {}) {
|
|
175
215
|
const manifest = await readProjectMemoryManifest();
|
|
176
216
|
const entry = manifest.projects.find((p) => p.id === id);
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import { workerReviewLineageDiagnostics } from '../models/worker-review-lineage.js';
|
|
3
3
|
import { WorkerContractError, } from './types.js';
|
|
4
4
|
function fail(message) { throw new WorkerContractError('OG_CONTRACT_INVALID', message); }
|
|
5
|
+
/** Read an existing verifier verdict; never promote worker completion to acceptance. */
|
|
6
|
+
export function hasIndependentWorkerAcceptance(verification) {
|
|
7
|
+
return verification.status === 'accepted'
|
|
8
|
+
&& !!verification.reviewRounds?.length
|
|
9
|
+
&& verification.evidence.length > 0
|
|
10
|
+
&& workerReviewEvidenceErrors(verification).length === 0;
|
|
11
|
+
}
|
|
5
12
|
/** Additional relational checks after JSON Schema shape validation. */
|
|
6
13
|
export function workerReviewEvidenceErrors(verification) {
|
|
7
14
|
const errors = [];
|