@codecell-germany/company-agent-wiki-skill 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -153
- package/dist/index.js +142 -95
- package/dist/installer.js +51 -16
- package/knowledge/ARCHITECTURE.md +3 -2
- package/knowledge/KNOWN_LIMITATIONS.md +1 -0
- package/knowledge/RELEASE_CHECKLIST.md +6 -2
- package/package.json +2 -2
- package/skills/company-agent-wiki-cli/SKILL.md +25 -7
- package/skills/company-agent-wiki-cli/references/agent-onboarding.md +3 -0
- package/skills/company-agent-wiki-cli/references/command-cheatsheet.md +3 -0
- package/skills/company-agent-wiki-cli/references/company-onboarding.md +1 -1
- package/skills/company-agent-wiki-cli/references/overview.md +1 -0
- package/skills/company-agent-wiki-cli/references/workspace-first-run.md +4 -1
package/dist/index.js
CHANGED
|
@@ -1189,7 +1189,7 @@ var require_command = __commonJS({
|
|
|
1189
1189
|
"node_modules/commander/lib/command.js"(exports2) {
|
|
1190
1190
|
var EventEmitter = require("node:events").EventEmitter;
|
|
1191
1191
|
var childProcess = require("node:child_process");
|
|
1192
|
-
var
|
|
1192
|
+
var path10 = require("node:path");
|
|
1193
1193
|
var fs9 = require("node:fs");
|
|
1194
1194
|
var process2 = require("node:process");
|
|
1195
1195
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2202,9 +2202,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2202
2202
|
let launchWithNode = false;
|
|
2203
2203
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2204
2204
|
function findFile(baseDir, baseName) {
|
|
2205
|
-
const localBin =
|
|
2205
|
+
const localBin = path10.resolve(baseDir, baseName);
|
|
2206
2206
|
if (fs9.existsSync(localBin)) return localBin;
|
|
2207
|
-
if (sourceExt.includes(
|
|
2207
|
+
if (sourceExt.includes(path10.extname(baseName))) return void 0;
|
|
2208
2208
|
const foundExt = sourceExt.find(
|
|
2209
2209
|
(ext) => fs9.existsSync(`${localBin}${ext}`)
|
|
2210
2210
|
);
|
|
@@ -2222,17 +2222,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2222
2222
|
} catch {
|
|
2223
2223
|
resolvedScriptPath = this._scriptPath;
|
|
2224
2224
|
}
|
|
2225
|
-
executableDir =
|
|
2226
|
-
|
|
2225
|
+
executableDir = path10.resolve(
|
|
2226
|
+
path10.dirname(resolvedScriptPath),
|
|
2227
2227
|
executableDir
|
|
2228
2228
|
);
|
|
2229
2229
|
}
|
|
2230
2230
|
if (executableDir) {
|
|
2231
2231
|
let localFile = findFile(executableDir, executableFile);
|
|
2232
2232
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2233
|
-
const legacyName =
|
|
2233
|
+
const legacyName = path10.basename(
|
|
2234
2234
|
this._scriptPath,
|
|
2235
|
-
|
|
2235
|
+
path10.extname(this._scriptPath)
|
|
2236
2236
|
);
|
|
2237
2237
|
if (legacyName !== this._name) {
|
|
2238
2238
|
localFile = findFile(
|
|
@@ -2243,7 +2243,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2243
2243
|
}
|
|
2244
2244
|
executableFile = localFile || executableFile;
|
|
2245
2245
|
}
|
|
2246
|
-
launchWithNode = sourceExt.includes(
|
|
2246
|
+
launchWithNode = sourceExt.includes(path10.extname(executableFile));
|
|
2247
2247
|
let proc;
|
|
2248
2248
|
if (process2.platform !== "win32") {
|
|
2249
2249
|
if (launchWithNode) {
|
|
@@ -3158,7 +3158,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3158
3158
|
* @return {Command}
|
|
3159
3159
|
*/
|
|
3160
3160
|
nameFromFilename(filename) {
|
|
3161
|
-
this._name =
|
|
3161
|
+
this._name = path10.basename(filename, path10.extname(filename));
|
|
3162
3162
|
return this;
|
|
3163
3163
|
}
|
|
3164
3164
|
/**
|
|
@@ -3172,9 +3172,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3172
3172
|
* @param {string} [path]
|
|
3173
3173
|
* @return {(string|null|Command)}
|
|
3174
3174
|
*/
|
|
3175
|
-
executableDir(
|
|
3176
|
-
if (
|
|
3177
|
-
this._executableDir =
|
|
3175
|
+
executableDir(path11) {
|
|
3176
|
+
if (path11 === void 0) return this._executableDir;
|
|
3177
|
+
this._executableDir = path11;
|
|
3178
3178
|
return this;
|
|
3179
3179
|
}
|
|
3180
3180
|
/**
|
|
@@ -6937,7 +6937,7 @@ var require_gray_matter = __commonJS({
|
|
|
6937
6937
|
|
|
6938
6938
|
// src/index.ts
|
|
6939
6939
|
var import_node_fs8 = __toESM(require("node:fs"));
|
|
6940
|
-
var
|
|
6940
|
+
var import_node_path9 = __toESM(require("node:path"));
|
|
6941
6941
|
|
|
6942
6942
|
// node_modules/commander/esm.mjs
|
|
6943
6943
|
var import_index = __toESM(require_commander(), 1);
|
|
@@ -6959,6 +6959,7 @@ var {
|
|
|
6959
6959
|
// src/lib/constants.ts
|
|
6960
6960
|
var PACKAGE_NAME = "@codecell-germany/company-agent-wiki-skill";
|
|
6961
6961
|
var CLI_NAME = "company-agent-wiki-cli";
|
|
6962
|
+
var SKILL_NAME = "company-agent-wiki-cli";
|
|
6962
6963
|
var WORKSPACE_INTERNAL_DIR = ".company-agent-wiki";
|
|
6963
6964
|
var WORKSPACE_CONFIG_FILE = "workspace.json";
|
|
6964
6965
|
var INDEX_DB_FILE = "index.sqlite";
|
|
@@ -7141,10 +7142,8 @@ function getGitDiff(filePath, baseRef, compareRef) {
|
|
|
7141
7142
|
return runGit(args, resolved.repoRoot, true);
|
|
7142
7143
|
}
|
|
7143
7144
|
|
|
7144
|
-
// src/lib/
|
|
7145
|
-
var
|
|
7146
|
-
var import_node_path6 = __toESM(require("node:path"));
|
|
7147
|
-
var import_better_sqlite3 = __toESM(require("better-sqlite3"));
|
|
7145
|
+
// src/lib/install.ts
|
|
7146
|
+
var import_node_path3 = __toESM(require("node:path"));
|
|
7148
7147
|
|
|
7149
7148
|
// src/lib/fs-utils.ts
|
|
7150
7149
|
var import_node_fs2 = __toESM(require("node:fs"));
|
|
@@ -7161,12 +7160,13 @@ function writeJsonFile(targetPath, value) {
|
|
|
7161
7160
|
`);
|
|
7162
7161
|
}
|
|
7163
7162
|
function writeJsonAtomic(targetPath, value) {
|
|
7164
|
-
const tempPath = `${targetPath}.tmp`;
|
|
7163
|
+
const tempPath = `${targetPath}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
7164
|
+
ensureDir(import_node_path2.default.dirname(targetPath));
|
|
7165
7165
|
writeJsonFile(tempPath, value);
|
|
7166
7166
|
import_node_fs2.default.renameSync(tempPath, targetPath);
|
|
7167
7167
|
}
|
|
7168
7168
|
function replaceFileAtomic(targetPath, content) {
|
|
7169
|
-
const tempPath = `${targetPath}.tmp`;
|
|
7169
|
+
const tempPath = `${targetPath}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
7170
7170
|
ensureDir(import_node_path2.default.dirname(targetPath));
|
|
7171
7171
|
import_node_fs2.default.writeFileSync(tempPath, content);
|
|
7172
7172
|
import_node_fs2.default.renameSync(tempPath, targetPath);
|
|
@@ -7203,6 +7203,25 @@ function walkMarkdownFiles(rootPath) {
|
|
|
7203
7203
|
return files.sort();
|
|
7204
7204
|
}
|
|
7205
7205
|
|
|
7206
|
+
// src/lib/install.ts
|
|
7207
|
+
function detectInstalledRuntimeHome(runtimeDir) {
|
|
7208
|
+
const normalized = import_node_path3.default.resolve(runtimeDir);
|
|
7209
|
+
const skillDir = import_node_path3.default.dirname(normalized);
|
|
7210
|
+
const toolsDir = import_node_path3.default.dirname(skillDir);
|
|
7211
|
+
if (import_node_path3.default.basename(normalized) !== "dist") {
|
|
7212
|
+
return void 0;
|
|
7213
|
+
}
|
|
7214
|
+
if (import_node_path3.default.basename(skillDir) !== SKILL_NAME || import_node_path3.default.basename(toolsDir) !== "tools") {
|
|
7215
|
+
return void 0;
|
|
7216
|
+
}
|
|
7217
|
+
return import_node_path3.default.dirname(toolsDir);
|
|
7218
|
+
}
|
|
7219
|
+
|
|
7220
|
+
// src/lib/indexer.ts
|
|
7221
|
+
var import_node_fs5 = __toESM(require("node:fs"));
|
|
7222
|
+
var import_node_path7 = __toESM(require("node:path"));
|
|
7223
|
+
var import_better_sqlite3 = __toESM(require("better-sqlite3"));
|
|
7224
|
+
|
|
7206
7225
|
// src/lib/hash.ts
|
|
7207
7226
|
var import_node_crypto = require("node:crypto");
|
|
7208
7227
|
function sha256(input) {
|
|
@@ -7213,7 +7232,7 @@ function newBuildId() {
|
|
|
7213
7232
|
}
|
|
7214
7233
|
|
|
7215
7234
|
// src/lib/markdown.ts
|
|
7216
|
-
var
|
|
7235
|
+
var import_node_path4 = __toESM(require("node:path"));
|
|
7217
7236
|
var import_gray_matter = __toESM(require_gray_matter());
|
|
7218
7237
|
function slugify(value) {
|
|
7219
7238
|
return value.normalize("NFKD").replace(/[^\w\s-]/g, "").trim().toLowerCase().replace(/[\s_]+/g, "-").replace(/-+/g, "-");
|
|
@@ -7263,7 +7282,7 @@ function parseMarkdownDocument(absPath, relPath, rootId, rawContent, mtimeMs) {
|
|
|
7263
7282
|
});
|
|
7264
7283
|
};
|
|
7265
7284
|
const titleFromFirstHeading = lines.find((line) => line.startsWith("# "))?.replace(/^#\s+/u, "").trim();
|
|
7266
|
-
const title = typeof parsed.data.title === "string" && parsed.data.title.trim() || titleFromFirstHeading ||
|
|
7285
|
+
const title = typeof parsed.data.title === "string" && parsed.data.title.trim() || titleFromFirstHeading || import_node_path4.default.basename(relPath, ".md");
|
|
7267
7286
|
const documentId = typeof parsed.data.id === "string" && parsed.data.id.trim() || deriveDocId(rootId, relPath);
|
|
7268
7287
|
for (const line of lines) {
|
|
7269
7288
|
const match = line.match(headingPattern);
|
|
@@ -7339,52 +7358,55 @@ function parseMarkdownDocument(absPath, relPath, rootId, rawContent, mtimeMs) {
|
|
|
7339
7358
|
// src/lib/workspace.ts
|
|
7340
7359
|
var import_node_fs3 = __toESM(require("node:fs"));
|
|
7341
7360
|
var import_node_os = __toESM(require("node:os"));
|
|
7342
|
-
var
|
|
7361
|
+
var import_node_path5 = __toESM(require("node:path"));
|
|
7343
7362
|
function getDefaultCodexHome() {
|
|
7344
|
-
return process.env.CODEX_HOME ||
|
|
7363
|
+
return process.env.CODEX_HOME || import_node_path5.default.join(import_node_os.default.homedir(), ".codex");
|
|
7364
|
+
}
|
|
7365
|
+
function getDefaultAgentsHome() {
|
|
7366
|
+
return process.env.AGENTS_HOME || import_node_path5.default.join(import_node_os.default.homedir(), ".agents");
|
|
7345
7367
|
}
|
|
7346
7368
|
function getGlobalRegistryDir() {
|
|
7347
7369
|
const explicit = process.env.COMPANY_AGENT_WIKI_CONFIG_HOME;
|
|
7348
7370
|
if (explicit?.trim()) {
|
|
7349
|
-
return
|
|
7371
|
+
return import_node_path5.default.resolve(explicit);
|
|
7350
7372
|
}
|
|
7351
7373
|
if (process.env.VITEST || process.env.NODE_ENV === "test") {
|
|
7352
|
-
return
|
|
7374
|
+
return import_node_path5.default.join(import_node_os.default.tmpdir(), GLOBAL_REGISTRY_DIR_NAME, "vitest");
|
|
7353
7375
|
}
|
|
7354
7376
|
if (process.platform === "darwin") {
|
|
7355
|
-
return
|
|
7377
|
+
return import_node_path5.default.join(import_node_os.default.homedir(), "Library", "Application Support", GLOBAL_REGISTRY_DIR_NAME);
|
|
7356
7378
|
}
|
|
7357
7379
|
if (process.platform === "win32") {
|
|
7358
|
-
const roaming = process.env.APPDATA ||
|
|
7359
|
-
return
|
|
7380
|
+
const roaming = process.env.APPDATA || import_node_path5.default.join(import_node_os.default.homedir(), "AppData", "Roaming");
|
|
7381
|
+
return import_node_path5.default.join(roaming, GLOBAL_REGISTRY_DIR_NAME);
|
|
7360
7382
|
}
|
|
7361
|
-
const xdgConfig = process.env.XDG_CONFIG_HOME ||
|
|
7362
|
-
return
|
|
7383
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || import_node_path5.default.join(import_node_os.default.homedir(), ".config");
|
|
7384
|
+
return import_node_path5.default.join(xdgConfig, GLOBAL_REGISTRY_DIR_NAME);
|
|
7363
7385
|
}
|
|
7364
7386
|
function getGlobalRegistryPath() {
|
|
7365
|
-
return
|
|
7387
|
+
return import_node_path5.default.join(getGlobalRegistryDir(), GLOBAL_REGISTRY_FILE);
|
|
7366
7388
|
}
|
|
7367
7389
|
function resolveWorkspacePaths(workspaceRoot) {
|
|
7368
7390
|
const absoluteRoot = normalizeWorkspaceRootPath(workspaceRoot);
|
|
7369
|
-
const internalDir =
|
|
7391
|
+
const internalDir = import_node_path5.default.join(absoluteRoot, WORKSPACE_INTERNAL_DIR);
|
|
7370
7392
|
return {
|
|
7371
7393
|
workspaceRoot: absoluteRoot,
|
|
7372
7394
|
internalDir,
|
|
7373
|
-
configPath:
|
|
7374
|
-
indexDbPath:
|
|
7375
|
-
indexManifestPath:
|
|
7376
|
-
managedRootPath:
|
|
7377
|
-
archiveRootPath:
|
|
7395
|
+
configPath: import_node_path5.default.join(internalDir, WORKSPACE_CONFIG_FILE),
|
|
7396
|
+
indexDbPath: import_node_path5.default.join(internalDir, INDEX_DB_FILE),
|
|
7397
|
+
indexManifestPath: import_node_path5.default.join(internalDir, INDEX_MANIFEST_FILE),
|
|
7398
|
+
managedRootPath: import_node_path5.default.join(absoluteRoot, DEFAULT_MANAGED_ROOT_PATH),
|
|
7399
|
+
archiveRootPath: import_node_path5.default.join(absoluteRoot, DEFAULT_ARCHIVE_ROOT_PATH)
|
|
7378
7400
|
};
|
|
7379
7401
|
}
|
|
7380
7402
|
function detectWorkspaceRoot(startDir = process.cwd()) {
|
|
7381
|
-
let current =
|
|
7403
|
+
let current = import_node_path5.default.resolve(startDir);
|
|
7382
7404
|
while (true) {
|
|
7383
|
-
const candidate =
|
|
7405
|
+
const candidate = import_node_path5.default.join(current, WORKSPACE_INTERNAL_DIR, WORKSPACE_CONFIG_FILE);
|
|
7384
7406
|
if (fileExists(candidate)) {
|
|
7385
7407
|
return current;
|
|
7386
7408
|
}
|
|
7387
|
-
const parent =
|
|
7409
|
+
const parent = import_node_path5.default.dirname(current);
|
|
7388
7410
|
if (parent === current) {
|
|
7389
7411
|
return void 0;
|
|
7390
7412
|
}
|
|
@@ -7399,7 +7421,7 @@ function createDefaultGlobalRegistry() {
|
|
|
7399
7421
|
};
|
|
7400
7422
|
}
|
|
7401
7423
|
function normalizeWorkspaceRootPath(candidatePath) {
|
|
7402
|
-
const resolved =
|
|
7424
|
+
const resolved = import_node_path5.default.resolve(candidatePath);
|
|
7403
7425
|
try {
|
|
7404
7426
|
return import_node_fs3.default.realpathSync.native ? import_node_fs3.default.realpathSync.native(resolved) : import_node_fs3.default.realpathSync(resolved);
|
|
7405
7427
|
} catch {
|
|
@@ -7424,7 +7446,7 @@ function loadGlobalWorkspaceRegistry() {
|
|
|
7424
7446
|
const normalizedEntry = {
|
|
7425
7447
|
workspaceId: entry.workspaceId,
|
|
7426
7448
|
path: normalizedPath,
|
|
7427
|
-
label: entry.label ||
|
|
7449
|
+
label: entry.label || import_node_path5.default.basename(normalizedPath),
|
|
7428
7450
|
registeredAt: entry.registeredAt,
|
|
7429
7451
|
lastUsedAt: entry.lastUsedAt,
|
|
7430
7452
|
source: entry.source
|
|
@@ -7458,14 +7480,14 @@ function buildRegisteredWorkspace(workspaceRoot, source) {
|
|
|
7458
7480
|
return {
|
|
7459
7481
|
workspaceId: config.workspaceId,
|
|
7460
7482
|
path: resolvedRoot,
|
|
7461
|
-
label:
|
|
7483
|
+
label: import_node_path5.default.basename(resolvedRoot),
|
|
7462
7484
|
registeredAt: now,
|
|
7463
7485
|
lastUsedAt: now,
|
|
7464
7486
|
source
|
|
7465
7487
|
};
|
|
7466
7488
|
}
|
|
7467
7489
|
function registerWorkspaceGlobally(workspaceRoot, options3) {
|
|
7468
|
-
const resolvedRoot =
|
|
7490
|
+
const resolvedRoot = import_node_path5.default.resolve(workspaceRoot);
|
|
7469
7491
|
const nextEntry = buildRegisteredWorkspace(resolvedRoot, options3?.source || "manual");
|
|
7470
7492
|
const registry = loadGlobalWorkspaceRegistry();
|
|
7471
7493
|
const existing = registry.workspaces.find((item) => item.path === resolvedRoot);
|
|
@@ -7817,8 +7839,8 @@ function createDefaultConfig() {
|
|
|
7817
7839
|
}
|
|
7818
7840
|
],
|
|
7819
7841
|
index: {
|
|
7820
|
-
databasePath:
|
|
7821
|
-
manifestPath:
|
|
7842
|
+
databasePath: import_node_path5.default.join(WORKSPACE_INTERNAL_DIR, INDEX_DB_FILE),
|
|
7843
|
+
manifestPath: import_node_path5.default.join(WORKSPACE_INTERNAL_DIR, INDEX_MANIFEST_FILE)
|
|
7822
7844
|
},
|
|
7823
7845
|
git: {
|
|
7824
7846
|
enabled: true,
|
|
@@ -7846,22 +7868,22 @@ function saveWorkspaceConfig(workspaceRoot, config) {
|
|
|
7846
7868
|
writeJsonFile(paths.configPath, config);
|
|
7847
7869
|
}
|
|
7848
7870
|
function normalizeStoredRootPath(workspaceRoot, candidatePath) {
|
|
7849
|
-
const absoluteCandidate =
|
|
7850
|
-
const relative =
|
|
7851
|
-
if (!relative.startsWith("..") && !
|
|
7871
|
+
const absoluteCandidate = import_node_path5.default.resolve(candidatePath);
|
|
7872
|
+
const relative = import_node_path5.default.relative(workspaceRoot, absoluteCandidate);
|
|
7873
|
+
if (!relative.startsWith("..") && !import_node_path5.default.isAbsolute(relative)) {
|
|
7852
7874
|
return relative || ".";
|
|
7853
7875
|
}
|
|
7854
7876
|
return absoluteCandidate;
|
|
7855
7877
|
}
|
|
7856
7878
|
function isPathInsideWorkspace(workspaceRoot, candidatePath) {
|
|
7857
|
-
const relative =
|
|
7858
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
7879
|
+
const relative = import_node_path5.default.relative(import_node_path5.default.resolve(workspaceRoot), import_node_path5.default.resolve(candidatePath));
|
|
7880
|
+
return relative === "" || !relative.startsWith("..") && !import_node_path5.default.isAbsolute(relative);
|
|
7859
7881
|
}
|
|
7860
7882
|
function resolveRootPath(workspaceRoot, root) {
|
|
7861
|
-
if (
|
|
7883
|
+
if (import_node_path5.default.isAbsolute(root.path)) {
|
|
7862
7884
|
return root.path;
|
|
7863
7885
|
}
|
|
7864
|
-
return
|
|
7886
|
+
return import_node_path5.default.join(workspaceRoot, root.path);
|
|
7865
7887
|
}
|
|
7866
7888
|
function setupWorkspace(options3) {
|
|
7867
7889
|
const paths = resolveWorkspacePaths(options3.workspaceRoot);
|
|
@@ -7883,20 +7905,20 @@ function setupWorkspace(options3) {
|
|
|
7883
7905
|
config.git.remoteConfigured = true;
|
|
7884
7906
|
}
|
|
7885
7907
|
saveWorkspaceConfig(paths.workspaceRoot, config);
|
|
7886
|
-
writeTextFile(
|
|
7887
|
-
writeTextFile(
|
|
7888
|
-
writeTextFile(
|
|
7889
|
-
writeTextFile(
|
|
7908
|
+
writeTextFile(import_node_path5.default.join(paths.workspaceRoot, "README.md"), templateWorkspaceReadme());
|
|
7909
|
+
writeTextFile(import_node_path5.default.join(paths.workspaceRoot, ".gitignore"), templateWorkspaceGitignore());
|
|
7910
|
+
writeTextFile(import_node_path5.default.join(paths.managedRootPath, "README.md"), templateKnowledgeReadme());
|
|
7911
|
+
writeTextFile(import_node_path5.default.join(paths.archiveRootPath, "README.md"), "# Archive\n");
|
|
7890
7912
|
const created = [
|
|
7891
7913
|
paths.configPath,
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7914
|
+
import_node_path5.default.join(paths.workspaceRoot, "README.md"),
|
|
7915
|
+
import_node_path5.default.join(paths.workspaceRoot, ".gitignore"),
|
|
7916
|
+
import_node_path5.default.join(paths.managedRootPath, "README.md"),
|
|
7917
|
+
import_node_path5.default.join(paths.archiveRootPath, "README.md")
|
|
7896
7918
|
];
|
|
7897
7919
|
if (options3.starterDocs !== false) {
|
|
7898
7920
|
for (const document of createStarterDocuments()) {
|
|
7899
|
-
const absPath =
|
|
7921
|
+
const absPath = import_node_path5.default.join(paths.managedRootPath, document.relPath);
|
|
7900
7922
|
writeTextFile(absPath, document.content);
|
|
7901
7923
|
created.push(absPath);
|
|
7902
7924
|
}
|
|
@@ -7932,7 +7954,7 @@ function addRoot(workspaceRoot, rootDefinition) {
|
|
|
7932
7954
|
if (config.roots.some((root2) => root2.id === rootDefinition.id)) {
|
|
7933
7955
|
throw new CliError("ROOT_EXISTS", `Root '${rootDefinition.id}' already exists.`, EXIT_CODES.validation);
|
|
7934
7956
|
}
|
|
7935
|
-
const absoluteRoot =
|
|
7957
|
+
const absoluteRoot = import_node_path5.default.resolve(rootDefinition.rootPath);
|
|
7936
7958
|
if (!isDirectory(absoluteRoot)) {
|
|
7937
7959
|
throw new CliError(
|
|
7938
7960
|
"ROOT_NOT_FOUND",
|
|
@@ -7974,10 +7996,13 @@ function listRoots(workspaceRoot) {
|
|
|
7974
7996
|
function doctor(workspaceRoot) {
|
|
7975
7997
|
const paths = resolveWorkspacePaths(workspaceRoot);
|
|
7976
7998
|
const checks = [];
|
|
7999
|
+
const agentsHome = getDefaultAgentsHome();
|
|
8000
|
+
const agentsBinDir = import_node_path5.default.join(agentsHome, "bin");
|
|
8001
|
+
const agentsShimPath = import_node_path5.default.join(agentsBinDir, CLI_NAME);
|
|
7977
8002
|
const codexHome = getDefaultCodexHome();
|
|
7978
|
-
const codexBinDir =
|
|
7979
|
-
const codexShimPath =
|
|
7980
|
-
const pathEntries = (process.env.PATH || "").split(
|
|
8003
|
+
const codexBinDir = import_node_path5.default.join(codexHome, "bin");
|
|
8004
|
+
const codexShimPath = import_node_path5.default.join(codexBinDir, CLI_NAME);
|
|
8005
|
+
const pathEntries = (process.env.PATH || "").split(import_node_path5.default.delimiter).filter(Boolean);
|
|
7981
8006
|
const registryPath = getGlobalRegistryPath();
|
|
7982
8007
|
const registry = loadGlobalWorkspaceRegistry();
|
|
7983
8008
|
checks.push({
|
|
@@ -7995,10 +8020,20 @@ function doctor(workspaceRoot) {
|
|
|
7995
8020
|
ok: isGitAvailable(),
|
|
7996
8021
|
message: isGitAvailable() ? "Git is available in PATH." : "Git is not available in PATH."
|
|
7997
8022
|
});
|
|
8023
|
+
checks.push({
|
|
8024
|
+
name: "agents-cli-shim",
|
|
8025
|
+
ok: fileExists(agentsShimPath),
|
|
8026
|
+
message: fileExists(agentsShimPath) ? `Shared agent CLI shim found: ${agentsShimPath}` : `Shared agent CLI shim missing: ${agentsShimPath}`
|
|
8027
|
+
});
|
|
8028
|
+
checks.push({
|
|
8029
|
+
name: "agents-bin-in-path",
|
|
8030
|
+
ok: pathEntries.includes(agentsBinDir),
|
|
8031
|
+
message: pathEntries.includes(agentsBinDir) ? `Shared agent bin directory is available in PATH: ${agentsBinDir}` : `Shared agent bin directory is not in PATH: ${agentsBinDir}`
|
|
8032
|
+
});
|
|
7998
8033
|
checks.push({
|
|
7999
8034
|
name: "codex-cli-shim",
|
|
8000
8035
|
ok: fileExists(codexShimPath),
|
|
8001
|
-
message: fileExists(codexShimPath) ? `Codex
|
|
8036
|
+
message: fileExists(codexShimPath) ? `Codex compatibility shim found: ${codexShimPath}` : `Codex compatibility shim missing: ${codexShimPath}`
|
|
8002
8037
|
});
|
|
8003
8038
|
checks.push({
|
|
8004
8039
|
name: "codex-bin-in-path",
|
|
@@ -8044,7 +8079,7 @@ function doctor(workspaceRoot) {
|
|
|
8044
8079
|
|
|
8045
8080
|
// src/lib/write-lock.ts
|
|
8046
8081
|
var import_node_fs4 = __toESM(require("node:fs"));
|
|
8047
|
-
var
|
|
8082
|
+
var import_node_path6 = __toESM(require("node:path"));
|
|
8048
8083
|
var LOCK_FILE_NAME = "write.lock";
|
|
8049
8084
|
var LOCK_WAIT_TIMEOUT_MS = 6e4;
|
|
8050
8085
|
var LOCK_POLL_INTERVAL_MS = 125;
|
|
@@ -8055,7 +8090,7 @@ function sleepMs(durationMs) {
|
|
|
8055
8090
|
Atomics.wait(array, 0, 0, durationMs);
|
|
8056
8091
|
}
|
|
8057
8092
|
function getLockPath(workspaceRoot) {
|
|
8058
|
-
return
|
|
8093
|
+
return import_node_path6.default.join(import_node_path6.default.resolve(workspaceRoot), WORKSPACE_INTERNAL_DIR, LOCK_FILE_NAME);
|
|
8059
8094
|
}
|
|
8060
8095
|
function readLockPayload(lockPath) {
|
|
8061
8096
|
if (!fileExists(lockPath)) {
|
|
@@ -8100,7 +8135,7 @@ function createLockPayload(workspaceRoot, reason) {
|
|
|
8100
8135
|
token: newBuildId(),
|
|
8101
8136
|
pid: process.pid,
|
|
8102
8137
|
reason,
|
|
8103
|
-
workspaceRoot:
|
|
8138
|
+
workspaceRoot: import_node_path6.default.resolve(workspaceRoot),
|
|
8104
8139
|
acquiredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8105
8140
|
};
|
|
8106
8141
|
}
|
|
@@ -8109,7 +8144,7 @@ function withWorkspaceWriteLock(workspaceRoot, reason, callback, options3) {
|
|
|
8109
8144
|
const timeoutMs = options3?.timeoutMs ?? LOCK_WAIT_TIMEOUT_MS;
|
|
8110
8145
|
const deadline = Date.now() + timeoutMs;
|
|
8111
8146
|
const payload = createLockPayload(workspaceRoot, reason);
|
|
8112
|
-
ensureDir(
|
|
8147
|
+
ensureDir(import_node_path6.default.dirname(lockPath));
|
|
8113
8148
|
while (true) {
|
|
8114
8149
|
try {
|
|
8115
8150
|
const fileDescriptor = import_node_fs4.default.openSync(lockPath, "wx");
|
|
@@ -8189,11 +8224,11 @@ function closeDatabaseQuietly(database) {
|
|
|
8189
8224
|
}
|
|
8190
8225
|
function throwKnownDatabaseError(error, workspaceRoot) {
|
|
8191
8226
|
const cliError = coerceCliError(error, {
|
|
8192
|
-
sqliteLockHint: `Retry in a moment, serialize parallel CLI reads against ${
|
|
8227
|
+
sqliteLockHint: `Retry in a moment, serialize parallel CLI reads against ${import_node_path7.default.resolve(
|
|
8193
8228
|
workspaceRoot
|
|
8194
8229
|
)}, or rerun with --auto-rebuild after the current write finishes.`,
|
|
8195
8230
|
sqliteLockDetails: {
|
|
8196
|
-
workspaceRoot:
|
|
8231
|
+
workspaceRoot: import_node_path7.default.resolve(workspaceRoot)
|
|
8197
8232
|
}
|
|
8198
8233
|
});
|
|
8199
8234
|
if (cliError) {
|
|
@@ -8276,7 +8311,7 @@ function collectRootSnapshot(rootId, rootPath, kind) {
|
|
|
8276
8311
|
let latestMtimeMs = 0;
|
|
8277
8312
|
for (const filePath of markdownFiles) {
|
|
8278
8313
|
const stats = import_node_fs5.default.statSync(filePath);
|
|
8279
|
-
const relPath =
|
|
8314
|
+
const relPath = import_node_path7.default.relative(rootPath, filePath);
|
|
8280
8315
|
latestMtimeMs = Math.max(latestMtimeMs, Math.trunc(stats.mtimeMs));
|
|
8281
8316
|
entries.push(`${relPath}|${stats.size}|${Math.trunc(stats.mtimeMs)}`);
|
|
8282
8317
|
}
|
|
@@ -8502,7 +8537,7 @@ function rebuildIndexUnlocked(workspaceRoot) {
|
|
|
8502
8537
|
for (const filePath of markdownFiles) {
|
|
8503
8538
|
const rawContent = import_node_fs5.default.readFileSync(filePath, "utf8");
|
|
8504
8539
|
const stats = import_node_fs5.default.statSync(filePath);
|
|
8505
|
-
const relPath =
|
|
8540
|
+
const relPath = import_node_path7.default.relative(rootPath, filePath);
|
|
8506
8541
|
const parsed = parseMarkdownDocument(filePath, relPath, root.id, rawContent, Math.trunc(stats.mtimeMs));
|
|
8507
8542
|
insertDocument(database, parsed.document);
|
|
8508
8543
|
insertSections(database, parsed.document, parsed.sections);
|
|
@@ -8614,7 +8649,7 @@ function requireFreshIndex(workspaceRoot, options3) {
|
|
|
8614
8649
|
"The workspace has not been indexed yet.",
|
|
8615
8650
|
EXIT_CODES.indexMissing,
|
|
8616
8651
|
{
|
|
8617
|
-
hint: verification.hint || `Run: company-agent-wiki-cli index rebuild --workspace ${
|
|
8652
|
+
hint: verification.hint || `Run: company-agent-wiki-cli index rebuild --workspace ${import_node_path7.default.resolve(workspaceRoot)}`
|
|
8618
8653
|
}
|
|
8619
8654
|
);
|
|
8620
8655
|
}
|
|
@@ -8627,7 +8662,7 @@ function requireFreshIndex(workspaceRoot, options3) {
|
|
|
8627
8662
|
"The indexed snapshot no longer matches the current roots.",
|
|
8628
8663
|
EXIT_CODES.indexStale,
|
|
8629
8664
|
{
|
|
8630
|
-
hint: `Run: company-agent-wiki-cli index rebuild --workspace ${
|
|
8665
|
+
hint: `Run: company-agent-wiki-cli index rebuild --workspace ${import_node_path7.default.resolve(workspaceRoot)}`,
|
|
8631
8666
|
details: verification.roots.filter((root) => !root.ok)
|
|
8632
8667
|
}
|
|
8633
8668
|
);
|
|
@@ -8937,7 +8972,7 @@ function getDocumentHeadings(workspaceRoot, docId, options3) {
|
|
|
8937
8972
|
|
|
8938
8973
|
// src/lib/onboarding.ts
|
|
8939
8974
|
var import_node_fs6 = __toESM(require("node:fs"));
|
|
8940
|
-
var
|
|
8975
|
+
var import_node_path8 = __toESM(require("node:path"));
|
|
8941
8976
|
var COMPANY_ONBOARDING_DE_V1 = {
|
|
8942
8977
|
profileId: "de-company-v1",
|
|
8943
8978
|
locale: "de-DE",
|
|
@@ -9529,8 +9564,8 @@ function ensureKnownAnswerKeys(payload) {
|
|
|
9529
9564
|
}
|
|
9530
9565
|
}
|
|
9531
9566
|
function isPathInsideWorkspace2(workspaceRoot, candidatePath) {
|
|
9532
|
-
const relative =
|
|
9533
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
9567
|
+
const relative = import_node_path8.default.relative(import_node_path8.default.resolve(workspaceRoot), import_node_path8.default.resolve(candidatePath));
|
|
9568
|
+
return relative === "" || !relative.startsWith("..") && !import_node_path8.default.isAbsolute(relative);
|
|
9534
9569
|
}
|
|
9535
9570
|
function resolveManagedRoot(workspaceRoot) {
|
|
9536
9571
|
const config = loadWorkspaceConfig(workspaceRoot);
|
|
@@ -9553,12 +9588,12 @@ function resolveManagedRoot(workspaceRoot) {
|
|
|
9553
9588
|
return resolvedPath;
|
|
9554
9589
|
}
|
|
9555
9590
|
function createDocument(workspaceRoot, managedRoot, relPath, id, title, type, tags, body, answeredAt, answeredBy) {
|
|
9556
|
-
const absPath =
|
|
9591
|
+
const absPath = import_node_path8.default.join(managedRoot, relPath);
|
|
9557
9592
|
return {
|
|
9558
9593
|
docId: id,
|
|
9559
9594
|
title,
|
|
9560
9595
|
absPath,
|
|
9561
|
-
relPath:
|
|
9596
|
+
relPath: import_node_path8.default.relative(workspaceRoot, absPath),
|
|
9562
9597
|
existed: false,
|
|
9563
9598
|
content: `${renderFrontmatter({ id, title, type, tags, answeredAt, answeredBy })}${body.trimEnd()}
|
|
9564
9599
|
`
|
|
@@ -9790,8 +9825,8 @@ function previewCompanyOnboarding(workspaceRoot, answerFile) {
|
|
|
9790
9825
|
};
|
|
9791
9826
|
}
|
|
9792
9827
|
function applyCompanyOnboarding(options3) {
|
|
9793
|
-
const workspaceRoot =
|
|
9794
|
-
const answerFile =
|
|
9828
|
+
const workspaceRoot = import_node_path8.default.resolve(options3.workspaceRoot);
|
|
9829
|
+
const answerFile = import_node_path8.default.resolve(options3.answerFile);
|
|
9795
9830
|
const preview = previewCompanyOnboarding(workspaceRoot, answerFile);
|
|
9796
9831
|
const warnings = [...preview.warnings];
|
|
9797
9832
|
let indexBuildId;
|
|
@@ -9817,7 +9852,7 @@ function applyCompanyOnboarding(options3) {
|
|
|
9817
9852
|
}
|
|
9818
9853
|
}
|
|
9819
9854
|
for (const document of preview.documents) {
|
|
9820
|
-
ensureDir(
|
|
9855
|
+
ensureDir(import_node_path8.default.dirname(document.absPath));
|
|
9821
9856
|
if (document.existed) {
|
|
9822
9857
|
warnings.push(`Overwriting existing file: ${document.relPath}`);
|
|
9823
9858
|
}
|
|
@@ -12509,7 +12544,7 @@ function startServer(workspaceRoot, port, options3) {
|
|
|
12509
12544
|
// src/index.ts
|
|
12510
12545
|
function assertWorkspace(workspacePath) {
|
|
12511
12546
|
if (workspacePath?.trim()) {
|
|
12512
|
-
const resolved =
|
|
12547
|
+
const resolved = import_node_path9.default.resolve(workspacePath);
|
|
12513
12548
|
rememberWorkspaceGlobally(resolved, { setDefault: true, source: "runtime" });
|
|
12514
12549
|
return resolved;
|
|
12515
12550
|
}
|
|
@@ -12596,14 +12631,20 @@ function printHeadings(headings) {
|
|
|
12596
12631
|
}
|
|
12597
12632
|
var program2 = new Command();
|
|
12598
12633
|
program2.name(CLI_NAME).description("Agent-first local company knowledge CLI").version(CLI_SCHEMA_VERSION);
|
|
12599
|
-
program2.command("about").description("Show CLI runtime metadata and common
|
|
12634
|
+
program2.command("about").description("Show CLI runtime metadata and common shared-agent paths").option("--json", "Emit JSON output", false).action((options3) => {
|
|
12635
|
+
const agentsHome = getDefaultAgentsHome();
|
|
12600
12636
|
const codexHome = getDefaultCodexHome();
|
|
12637
|
+
const runtimeHome = detectInstalledRuntimeHome(__dirname) || null;
|
|
12601
12638
|
const data = {
|
|
12602
12639
|
packageName: PACKAGE_NAME,
|
|
12603
12640
|
cliName: CLI_NAME,
|
|
12604
12641
|
schemaVersion: CLI_SCHEMA_VERSION,
|
|
12642
|
+
runtimeHome,
|
|
12643
|
+
runtimeShimPath: runtimeHome ? import_node_path9.default.join(runtimeHome, "bin", CLI_NAME) : null,
|
|
12644
|
+
agentsHome,
|
|
12645
|
+
agentsShimPath: import_node_path9.default.join(agentsHome, "bin", CLI_NAME),
|
|
12605
12646
|
codexHome,
|
|
12606
|
-
codexShimPath:
|
|
12647
|
+
codexShimPath: import_node_path9.default.join(codexHome, "bin", CLI_NAME),
|
|
12607
12648
|
cwdWorkspace: detectWorkspaceRoot(process.cwd()) || null,
|
|
12608
12649
|
globalRegistryPath: getGlobalRegistryPath(),
|
|
12609
12650
|
resolvedWorkspace: resolveWorkspaceSelection(process.cwd())
|
|
@@ -12615,6 +12656,12 @@ program2.command("about").description("Show CLI runtime metadata and common Code
|
|
|
12615
12656
|
process.stdout.write(`${CLI_NAME}
|
|
12616
12657
|
`);
|
|
12617
12658
|
process.stdout.write(` schema version: ${CLI_SCHEMA_VERSION}
|
|
12659
|
+
`);
|
|
12660
|
+
if (data.runtimeShimPath) {
|
|
12661
|
+
process.stdout.write(` runtime shim: ${data.runtimeShimPath}
|
|
12662
|
+
`);
|
|
12663
|
+
}
|
|
12664
|
+
process.stdout.write(` shared agent shim: ${data.agentsShimPath}
|
|
12618
12665
|
`);
|
|
12619
12666
|
process.stdout.write(` codex shim: ${data.codexShimPath}
|
|
12620
12667
|
`);
|
|
@@ -12679,7 +12726,7 @@ workspace.command("list").description("List globally registered workspaces").opt
|
|
|
12679
12726
|
}
|
|
12680
12727
|
});
|
|
12681
12728
|
workspace.command("register").description("Register an existing workspace globally for other agents").requiredOption("--workspace <path>", "Absolute or relative workspace path").option("--default", "Also mark this workspace as the global default", false).option("--json", "Emit JSON output", false).action((options3) => {
|
|
12682
|
-
const entry = registerWorkspaceGlobally(
|
|
12729
|
+
const entry = registerWorkspaceGlobally(import_node_path9.default.resolve(options3.workspace), {
|
|
12683
12730
|
setDefault: Boolean(options3.default),
|
|
12684
12731
|
source: "manual"
|
|
12685
12732
|
});
|
|
@@ -12698,7 +12745,7 @@ workspace.command("register").description("Register an existing workspace global
|
|
|
12698
12745
|
}
|
|
12699
12746
|
});
|
|
12700
12747
|
workspace.command("use").description("Set a registered workspace as the global default").requiredOption("--workspace <path>", "Absolute or relative workspace path").option("--json", "Emit JSON output", false).action((options3) => {
|
|
12701
|
-
const entry = registerWorkspaceGlobally(
|
|
12748
|
+
const entry = registerWorkspaceGlobally(import_node_path9.default.resolve(options3.workspace), {
|
|
12702
12749
|
setDefault: true,
|
|
12703
12750
|
source: "manual"
|
|
12704
12751
|
});
|
|
@@ -12716,7 +12763,7 @@ workspace.command("use").description("Set a registered workspace as the global d
|
|
|
12716
12763
|
program2.addCommand(workspace);
|
|
12717
12764
|
program2.command("setup").description("Workspace setup commands").addCommand(
|
|
12718
12765
|
new Command("workspace").requiredOption("--workspace <path>", "Absolute or relative workspace path").option("--git-init", "Initialize a local Git repository", false).option("--git-remote <url>", "Configure a Git remote URL").option("--no-starter-docs", "Skip creation of starter Markdown documents").option("--force", "Rewrite an existing scaffold", false).option("--json", "Emit JSON output", false).action((options3) => {
|
|
12719
|
-
const workspaceRoot =
|
|
12766
|
+
const workspaceRoot = import_node_path9.default.resolve(options3.workspace);
|
|
12720
12767
|
const result = setupWorkspace({
|
|
12721
12768
|
workspaceRoot,
|
|
12722
12769
|
gitInit: Boolean(options3.gitInit),
|
|
@@ -12970,8 +13017,8 @@ program2.command("read").option("--workspace <path>", "Workspace path. Optional
|
|
|
12970
13017
|
const metadataResult = options3.docId ? getDocumentMetadataById(workspaceRoot, options3.docId, {
|
|
12971
13018
|
autoRebuild: Boolean(options3.autoRebuild)
|
|
12972
13019
|
}) : (() => {
|
|
12973
|
-
const candidatePath =
|
|
12974
|
-
return getDocumentMetadataByPath(workspaceRoot,
|
|
13020
|
+
const candidatePath = import_node_path9.default.isAbsolute(options3.path) ? options3.path : import_node_path9.default.join(workspaceRoot, options3.path);
|
|
13021
|
+
return getDocumentMetadataByPath(workspaceRoot, import_node_path9.default.resolve(candidatePath), {
|
|
12975
13022
|
autoRebuild: Boolean(options3.autoRebuild)
|
|
12976
13023
|
});
|
|
12977
13024
|
})();
|
|
@@ -13021,7 +13068,7 @@ program2.command("read").option("--workspace <path>", "Workspace path. Optional
|
|
|
13021
13068
|
});
|
|
13022
13069
|
program2.command("history").option("--workspace <path>", "Workspace path. Optional when current directory is already inside a workspace.").option("--doc-id <id>", "Indexed document identifier").option("--path <path>", "Absolute or workspace-relative document path").option("--limit <number>", "Maximum number of commits", "20").option("--json", "Emit JSON output", false).action((options3) => {
|
|
13023
13070
|
const workspaceRoot = assertWorkspace(options3.workspace);
|
|
13024
|
-
const resolvedPath = options3.docId ? resolveDocumentById(workspaceRoot, options3.docId).absPath :
|
|
13071
|
+
const resolvedPath = options3.docId ? resolveDocumentById(workspaceRoot, options3.docId).absPath : import_node_path9.default.resolve(import_node_path9.default.isAbsolute(options3.path) ? options3.path : import_node_path9.default.join(workspaceRoot, options3.path));
|
|
13025
13072
|
const history = getGitHistory(resolvedPath, Number(options3.limit));
|
|
13026
13073
|
if (options3.json) {
|
|
13027
13074
|
printJson(envelope("history", { path: resolvedPath, history }));
|
|
@@ -13034,7 +13081,7 @@ program2.command("history").option("--workspace <path>", "Workspace path. Option
|
|
|
13034
13081
|
});
|
|
13035
13082
|
program2.command("diff").option("--workspace <path>", "Workspace path. Optional when current directory is already inside a workspace.").option("--doc-id <id>", "Indexed document identifier").option("--path <path>", "Absolute or workspace-relative document path").option("--base <ref>", "Base Git ref", "HEAD").option("--compare <ref>", "Optional compare ref").option("--json", "Emit JSON output", false).action((options3) => {
|
|
13036
13083
|
const workspaceRoot = assertWorkspace(options3.workspace);
|
|
13037
|
-
const resolvedPath = options3.docId ? resolveDocumentById(workspaceRoot, options3.docId).absPath :
|
|
13084
|
+
const resolvedPath = options3.docId ? resolveDocumentById(workspaceRoot, options3.docId).absPath : import_node_path9.default.resolve(import_node_path9.default.isAbsolute(options3.path) ? options3.path : import_node_path9.default.join(workspaceRoot, options3.path));
|
|
13038
13085
|
const diff = getGitDiff(resolvedPath, options3.base, options3.compare);
|
|
13039
13086
|
if (options3.json) {
|
|
13040
13087
|
printJson(envelope("diff", { path: resolvedPath, diff }));
|