@biaoo/tiangong-wiki 0.3.7 → 0.3.8
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/assets/config.example.env +4 -5
- package/dist/commands/check-config.js +16 -1
- package/dist/core/agent-auth.js +101 -0
- package/dist/core/codex-workflow.js +0 -4
- package/dist/core/onboarding.js +14 -1
- package/dist/core/paths.js +1 -1
- package/package.json +1 -1
- package/references/troubleshooting.md +21 -3
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ tiangong-wiki sync # index Markdown pages
|
|
|
86
86
|
|
|
87
87
|
That means commands still work best from inside a workspace, but they can also run from outside the workspace after setup, or target a specific workspace explicitly with `--env-file`.
|
|
88
88
|
|
|
89
|
-
For automatic vault processing, new setup runs default to `WIKI_AGENT_AUTH_MODE=codex-login`,
|
|
89
|
+
For automatic vault processing, new setup runs default to `WIKI_AGENT_AUTH_MODE=codex-login`, the current user's standard Codex home (`~/.codex`, or the user profile `.codex` directory on Windows), and `WIKI_AGENT_MODEL=gpt-5.5`. If you want an isolated Codex home, set `WIKI_AGENT_CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki` and first run `CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki codex login`.
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
92
|
tiangong-wiki find --type concept --status active # structured query
|
package/README.zh-CN.md
CHANGED
|
@@ -86,7 +86,7 @@ tiangong-wiki sync # 索引 Markdown 文件
|
|
|
86
86
|
|
|
87
87
|
这意味着命令仍然最适合在 workspace 内执行;但 setup 之后,即使在 workspace 外运行,也可以通过默认配置正常工作,或者通过 `--env-file` 显式指定目标工作区。
|
|
88
88
|
|
|
89
|
-
如果启用自动 vault 处理,新的 setup 默认使用 `WIKI_AGENT_AUTH_MODE=codex-login
|
|
89
|
+
如果启用自动 vault 处理,新的 setup 默认使用 `WIKI_AGENT_AUTH_MODE=codex-login`、当前用户标准 Codex home(Linux/macOS 为 `~/.codex`,Windows 为用户目录下的 `.codex`)和 `WIKI_AGENT_MODEL=gpt-5.5`。如果需要隔离目录,可手动设置 `WIKI_AGENT_CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki`,并先执行 `CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki codex login`。
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
92
|
tiangong-wiki find --type concept --status active # 结构化查询
|
|
@@ -11,12 +11,11 @@ EMBEDDING_MODEL=text-embedding-3-small
|
|
|
11
11
|
EMBEDDING_DIMENSIONS=1536
|
|
12
12
|
|
|
13
13
|
WIKI_AGENT_ENABLED=false
|
|
14
|
-
# For local Codex login auth, run
|
|
15
|
-
# CODEX_HOME="$HOME/.codex-tiangong-wiki" codex login
|
|
16
|
-
# On Windows PowerShell:
|
|
17
|
-
# $env:CODEX_HOME = "$env:USERPROFILE\.codex-tiangong-wiki"; codex login
|
|
14
|
+
# For local Codex login auth, run `codex login` once as the same user.
|
|
18
15
|
WIKI_AGENT_AUTH_MODE=codex-login
|
|
19
|
-
# Optional. Leave unset to use the current user's
|
|
16
|
+
# Optional. Leave unset to use the current user's standard Codex home: <home>/.codex
|
|
17
|
+
# For an isolated directory, set this to an absolute path and first run:
|
|
18
|
+
# CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki codex login
|
|
20
19
|
# WIKI_AGENT_CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki
|
|
21
20
|
#
|
|
22
21
|
# To use an API key instead of Codex login:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { inspectWikiAgentCodexLogin } from "../core/agent-auth.js";
|
|
2
3
|
import { loadRuntimeConfig } from "../core/runtime.js";
|
|
3
4
|
import { EmbeddingClient } from "../core/embedding.js";
|
|
4
5
|
import { getWikiAgentStatus } from "../core/vault-processing.js";
|
|
@@ -20,6 +21,17 @@ export function registerCheckConfigCommand(program) {
|
|
|
20
21
|
if (wikiAgent.enabled && wikiAgent.missing.length > 0) {
|
|
21
22
|
throw new AppError(`WIKI_AGENT_ENABLED=true but missing required settings: ${wikiAgent.missing.join(", ")}`, "config");
|
|
22
23
|
}
|
|
24
|
+
const agentCodexLogin = inspectWikiAgentCodexLogin(wikiAgent);
|
|
25
|
+
if (!agentCodexLogin.ready) {
|
|
26
|
+
throw new AppError([
|
|
27
|
+
agentCodexLogin.summary,
|
|
28
|
+
agentCodexLogin.recommendation,
|
|
29
|
+
].filter(Boolean).join(" "), "config");
|
|
30
|
+
}
|
|
31
|
+
const safeWikiAgent = {
|
|
32
|
+
...wikiAgent,
|
|
33
|
+
apiKey: wikiAgent.apiKey ? "<redacted>" : null,
|
|
34
|
+
};
|
|
23
35
|
const templateChecks = Object.keys(config.templates).map((pageType) => {
|
|
24
36
|
const templatePath = resolveTemplateFilePath(config, paths.wikiRoot, pageType);
|
|
25
37
|
return {
|
|
@@ -44,7 +56,8 @@ export function registerCheckConfigCommand(program) {
|
|
|
44
56
|
templatesPath: paths.templatesPath,
|
|
45
57
|
configVersion: config.configVersion,
|
|
46
58
|
embeddingConfigured: embeddingClient !== null,
|
|
47
|
-
agentProcessing:
|
|
59
|
+
agentProcessing: safeWikiAgent,
|
|
60
|
+
agentCodexLogin,
|
|
48
61
|
probe,
|
|
49
62
|
templateChecks,
|
|
50
63
|
};
|
|
@@ -70,6 +83,8 @@ export function registerCheckConfigCommand(program) {
|
|
|
70
83
|
agentBatchSize: wikiAgent.batchSize,
|
|
71
84
|
agentWorkflowTimeoutSeconds: wikiAgent.workflowTimeoutSeconds,
|
|
72
85
|
agentMissing: wikiAgent.missing.join(", "),
|
|
86
|
+
agentCodexLoginReady: agentCodexLogin.checked ? agentCodexLogin.ready : "",
|
|
87
|
+
agentCodexLoginAuthJson: agentCodexLogin.authJsonPath ?? "",
|
|
73
88
|
probe,
|
|
74
89
|
}),
|
|
75
90
|
"",
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function inspectPathKind(targetPath) {
|
|
4
|
+
try {
|
|
5
|
+
const stats = statSync(targetPath);
|
|
6
|
+
if (stats.isDirectory()) {
|
|
7
|
+
return { kind: "directory" };
|
|
8
|
+
}
|
|
9
|
+
if (stats.isFile()) {
|
|
10
|
+
return { kind: "file" };
|
|
11
|
+
}
|
|
12
|
+
return { kind: "other" };
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const code = error.code;
|
|
16
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
17
|
+
return { kind: "missing" };
|
|
18
|
+
}
|
|
19
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
20
|
+
return { kind: "inaccessible", errorMessage: message };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function codexLoginRecommendation(codexHome) {
|
|
24
|
+
return `Run \`CODEX_HOME=${codexHome} codex login\` before starting automatic vault processing.`;
|
|
25
|
+
}
|
|
26
|
+
export function inspectWikiAgentCodexLogin(settings) {
|
|
27
|
+
if (!settings.enabled || settings.authMode !== "codex-login") {
|
|
28
|
+
return {
|
|
29
|
+
checked: false,
|
|
30
|
+
ready: true,
|
|
31
|
+
codexHome: settings.codexHome,
|
|
32
|
+
authJsonPath: null,
|
|
33
|
+
summary: "Codex login auth is not enabled.",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (!settings.codexHome) {
|
|
37
|
+
return {
|
|
38
|
+
checked: true,
|
|
39
|
+
ready: false,
|
|
40
|
+
codexHome: null,
|
|
41
|
+
authJsonPath: null,
|
|
42
|
+
summary: "WIKI_AGENT_CODEX_HOME is not configured for codex-login auth.",
|
|
43
|
+
recommendation: "Set WIKI_AGENT_CODEX_HOME or rerun `tiangong-wiki setup`.",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const codexHome = settings.codexHome;
|
|
47
|
+
const authJsonPath = path.join(codexHome, "auth.json");
|
|
48
|
+
const home = inspectPathKind(codexHome);
|
|
49
|
+
if (home.kind === "missing") {
|
|
50
|
+
return {
|
|
51
|
+
checked: true,
|
|
52
|
+
ready: false,
|
|
53
|
+
codexHome,
|
|
54
|
+
authJsonPath,
|
|
55
|
+
summary: `WIKI_AGENT_CODEX_HOME does not exist: ${codexHome}`,
|
|
56
|
+
recommendation: codexLoginRecommendation(codexHome),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (home.kind !== "directory") {
|
|
60
|
+
return {
|
|
61
|
+
checked: true,
|
|
62
|
+
ready: false,
|
|
63
|
+
codexHome,
|
|
64
|
+
authJsonPath,
|
|
65
|
+
summary: home.kind === "inaccessible"
|
|
66
|
+
? `WIKI_AGENT_CODEX_HOME cannot be inspected: ${codexHome} (${home.errorMessage})`
|
|
67
|
+
: `WIKI_AGENT_CODEX_HOME is not a directory: ${codexHome}`,
|
|
68
|
+
recommendation: codexLoginRecommendation(codexHome),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const authJson = inspectPathKind(authJsonPath);
|
|
72
|
+
if (authJson.kind === "missing") {
|
|
73
|
+
return {
|
|
74
|
+
checked: true,
|
|
75
|
+
ready: false,
|
|
76
|
+
codexHome,
|
|
77
|
+
authJsonPath,
|
|
78
|
+
summary: `Codex login auth.json was not found under WIKI_AGENT_CODEX_HOME: ${authJsonPath}`,
|
|
79
|
+
recommendation: codexLoginRecommendation(codexHome),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (authJson.kind !== "file") {
|
|
83
|
+
return {
|
|
84
|
+
checked: true,
|
|
85
|
+
ready: false,
|
|
86
|
+
codexHome,
|
|
87
|
+
authJsonPath,
|
|
88
|
+
summary: authJson.kind === "inaccessible"
|
|
89
|
+
? `Codex login auth.json cannot be inspected: ${authJsonPath} (${authJson.errorMessage})`
|
|
90
|
+
: `Codex login auth.json is not a file: ${authJsonPath}`,
|
|
91
|
+
recommendation: codexLoginRecommendation(codexHome),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
checked: true,
|
|
96
|
+
ready: true,
|
|
97
|
+
codexHome,
|
|
98
|
+
authJsonPath,
|
|
99
|
+
summary: `Codex login auth is available at ${codexHome}.`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { mkdirSync } from "node:fs";
|
|
3
2
|
import childProcess from "node:child_process";
|
|
4
3
|
import { syncBuiltinESMExports } from "node:module";
|
|
5
4
|
import { readWorkflowResult } from "./workflow-result.js";
|
|
@@ -54,9 +53,6 @@ async function loadCodexSdk() {
|
|
|
54
53
|
}
|
|
55
54
|
function normalizeEnv(input) {
|
|
56
55
|
const agentSettings = resolveAgentSettings(input.env);
|
|
57
|
-
if (agentSettings.authMode === "codex-login" && agentSettings.codexHome) {
|
|
58
|
-
mkdirSync(agentSettings.codexHome, { recursive: true });
|
|
59
|
-
}
|
|
60
56
|
const normalized = {};
|
|
61
57
|
for (const [key, value] of Object.entries({
|
|
62
58
|
...process.env,
|
package/dist/core/onboarding.js
CHANGED
|
@@ -2,6 +2,7 @@ import { accessSync, constants, readFileSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
5
|
+
import { inspectWikiAgentCodexLogin } from "./agent-auth.js";
|
|
5
6
|
import { DEFAULT_WIKI_ENV_FILE, getCliEnvironmentInfo, parseEnvFile, serializeEnvEntries } from "./cli-env.js";
|
|
6
7
|
import { resolveTemplateFilePath, loadConfig } from "./config.js";
|
|
7
8
|
import { DEFAULT_EMBEDDING_DIMENSIONS, EmbeddingClient } from "./embedding.js";
|
|
@@ -496,7 +497,7 @@ async function collectAgentSettings(driver, ctx, defaults) {
|
|
|
496
497
|
{
|
|
497
498
|
value: "codex-login",
|
|
498
499
|
label: "codex-login",
|
|
499
|
-
description: "Use
|
|
500
|
+
description: "Use the current user's Codex login by default (~/.codex); set WIKI_AGENT_CODEX_HOME for isolation.",
|
|
500
501
|
},
|
|
501
502
|
{
|
|
502
503
|
value: "api-key",
|
|
@@ -792,6 +793,11 @@ export async function runSetupWizard(env = process.env, options = {}) {
|
|
|
792
793
|
`- Example: cd ${JSON.stringify(workspaceRoot)} && tiangong-wiki init`,
|
|
793
794
|
"- Run `tiangong-wiki doctor` to validate the generated configuration.",
|
|
794
795
|
"- Run `tiangong-wiki init` to create index.db and perform the first sync.",
|
|
796
|
+
...(values.agentEnabled && values.agentAuthMode === "codex-login" && values.agentCodexHome
|
|
797
|
+
? [
|
|
798
|
+
`- Codex login auth uses ${values.agentCodexHome}; if needed, run \`CODEX_HOME=${values.agentCodexHome} codex login\` before starting the daemon.`,
|
|
799
|
+
]
|
|
800
|
+
: []),
|
|
795
801
|
...(values.vaultSource === "synology"
|
|
796
802
|
? ["- Protect `.wiki.env` carefully because it now stores Synology credentials."]
|
|
797
803
|
: []),
|
|
@@ -969,6 +975,13 @@ function inspectAgent(checks, env) {
|
|
|
969
975
|
collectDoctorCheck(checks, "error", "agent", `Automatic vault processing is enabled but missing: ${settings.missing.join(", ")}`, "Set the missing WIKI_AGENT_* values in `.wiki.env` or rerun `tiangong-wiki setup`.");
|
|
970
976
|
return;
|
|
971
977
|
}
|
|
978
|
+
if (settings.authMode === "codex-login") {
|
|
979
|
+
const codexLogin = inspectWikiAgentCodexLogin(settings);
|
|
980
|
+
if (!codexLogin.ready) {
|
|
981
|
+
collectDoctorCheck(checks, "error", "agent", codexLogin.summary, codexLogin.recommendation);
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
972
985
|
collectDoctorCheck(checks, "ok", "agent", settings.authMode === "codex-login"
|
|
973
986
|
? `Automatic vault processing is enabled with model ${settings.model} via Codex login at ${settings.codexHome}.`
|
|
974
987
|
: `Automatic vault processing is enabled with model ${settings.model} via API key auth.`);
|
package/dist/core/paths.js
CHANGED
|
@@ -88,7 +88,7 @@ function normalizeOptionalAbsolutePath(label, rawValue) {
|
|
|
88
88
|
return path.resolve(value);
|
|
89
89
|
}
|
|
90
90
|
export function defaultWikiAgentCodexHome() {
|
|
91
|
-
return path.join(os.homedir(), ".codex
|
|
91
|
+
return path.join(os.homedir(), ".codex");
|
|
92
92
|
}
|
|
93
93
|
export function parseVaultHashMode(raw) {
|
|
94
94
|
const value = (raw ?? "content").trim().toLowerCase();
|
package/package.json
CHANGED
|
@@ -85,7 +85,7 @@ The agent uses [Codex SDK](https://www.npmjs.com/package/@openai/codex-sdk) to p
|
|
|
85
85
|
| --- | --- | --- |
|
|
86
86
|
| `WIKI_AGENT_ENABLED` | No | Enable agentic workflow (`true` / `false`, default: `false`) |
|
|
87
87
|
| `WIKI_AGENT_AUTH_MODE` | No | Auth mode: `api-key` or `codex-login`. Runtime default is `api-key` for backwards compatibility; `tiangong-wiki setup` defaults new agent configs to `codex-login` |
|
|
88
|
-
| `WIKI_AGENT_CODEX_HOME` | No |
|
|
88
|
+
| `WIKI_AGENT_CODEX_HOME` | No | Codex home directory. Leave unset to use the current user's standard `${HOME}/.codex` (or the user profile `.codex` directory on Windows); if set in `.wiki.env`, use a real absolute path because shell variables are not expanded there |
|
|
89
89
|
| `WIKI_AGENT_BASE_URL` | No | LLM API base URL for `api-key` mode (e.g. `https://api.openai.com/v1`). When set, overrides global Codex config |
|
|
90
90
|
| `WIKI_AGENT_API_KEY` | In `api-key` mode | API key for the LLM provider |
|
|
91
91
|
| `WIKI_AGENT_MODEL` | No | Model name (default: `gpt-5.5`; e.g. `Qwen/Qwen3.5-397B-A17B-GPTQ-Int4`) |
|
|
@@ -95,6 +95,8 @@ The agent uses [Codex SDK](https://www.npmjs.com/package/@openai/codex-sdk) to p
|
|
|
95
95
|
|
|
96
96
|
`tiangong-wiki setup` now prompts for `WIKI_AGENT_SANDBOX_MODE` when automatic vault processing is enabled. The default is `danger-full-access`, and the setup wizard highlights that this mode grants full runtime access.
|
|
97
97
|
|
|
98
|
+
When `WIKI_AGENT_ENABLED=true` and `WIKI_AGENT_AUTH_MODE=codex-login`, `tiangong-wiki doctor` and `tiangong-wiki check-config` verify that `WIKI_AGENT_CODEX_HOME` exists and contains `auth.json`. They report the path and remediation command, but never print token or auth file contents.
|
|
99
|
+
|
|
98
100
|
Queue items that fail workflow execution are auto-retried up to 3 times. After that they remain in `error` until you manually retry them from the dashboard / queue tooling, or a later vault sync requeues the file because the source changed.
|
|
99
101
|
|
|
100
102
|
---
|
|
@@ -148,7 +150,23 @@ If the agent workflow fails with `bwrap`, `unshare`, `uid_map`, or similar sandb
|
|
|
148
150
|
|
|
149
151
|
### Codex login (recommended local setup)
|
|
150
152
|
|
|
151
|
-
|
|
153
|
+
By default, use the current user's standard Codex home:
|
|
154
|
+
|
|
155
|
+
macOS/Linux:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
codex login
|
|
159
|
+
codex login status
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Windows PowerShell:
|
|
163
|
+
|
|
164
|
+
```powershell
|
|
165
|
+
codex login
|
|
166
|
+
codex login status
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
For an isolated Codex home, set `WIKI_AGENT_CODEX_HOME` to an absolute path and log in there first:
|
|
152
170
|
|
|
153
171
|
macOS/Linux:
|
|
154
172
|
|
|
@@ -172,7 +190,7 @@ Then configure the wiki agent:
|
|
|
172
190
|
```env
|
|
173
191
|
WIKI_AGENT_ENABLED=true
|
|
174
192
|
WIKI_AGENT_AUTH_MODE=codex-login
|
|
175
|
-
# Optional. Leave unset to use the current user's
|
|
193
|
+
# Optional. Leave unset to use the current user's standard ~/.codex.
|
|
176
194
|
# WIKI_AGENT_CODEX_HOME=/absolute/path/to/.codex-tiangong-wiki
|
|
177
195
|
WIKI_AGENT_MODEL=gpt-5.5
|
|
178
196
|
```
|