@deveco-test/deveco-code 1.0.3 → 1.0.4

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +6 -5
  3. package/resources/deveco/skills/customize-deveco/.deveco-builtin +1 -0
  4. package/resources/deveco/skills/customize-deveco/SKILL.md +469 -0
  5. package/resources/deveco/skills/deveco-cli/.deveco-builtin +1 -0
  6. package/resources/deveco/skills/deveco-cli/SKILL.md +240 -0
  7. package/resources/deveco/skills/hmos-arkui-develop-skill/.deveco-builtin +1 -0
  8. package/resources/deveco/skills/hmos-arkui-develop-skill/SKILL.md +83 -0
  9. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/01-layout.md +629 -0
  10. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/02-basic-components.md +645 -0
  11. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/03-data-display.md +81 -0
  12. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/04-selectors.md +76 -0
  13. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/05-media.md +60 -0
  14. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/06-advanced.md +32 -0
  15. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/07-security.md +30 -0
  16. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/08-state-decorators.md +79 -0
  17. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/09-animation.md +111 -0
  18. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/10-gesture.md +59 -0
  19. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/11-dialog-menu.md +92 -0
  20. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/12-navigation.md +81 -0
  21. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/13-rendering.md +22 -0
  22. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/14-extension.md +22 -0
  23. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/15-theme-style.md +10 -0
  24. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/16-enums.md +87 -0
  25. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/17-resources.md +1379 -0
  26. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/18-error-code.md +24 -0
  27. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-apis/_index.md +75 -0
  28. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/00-arkts-syntax.md +229 -0
  29. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/01-import.md +116 -0
  30. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/02-uicontext.md +56 -0
  31. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/03-component.md +105 -0
  32. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/04-build.md +41 -0
  33. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/05-state.md +300 -0
  34. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/06-rendering.md +67 -0
  35. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/07-attribute-params.md +219 -0
  36. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/08-navigation.md +102 -0
  37. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/09-dialog.md +72 -0
  38. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/10-style.md +90 -0
  39. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/11-extension.md +54 -0
  40. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/12-layout.md +69 -0
  41. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/13-performance.md +27 -0
  42. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/14-deprecated.md +28 -0
  43. package/resources/deveco/skills/hmos-arkui-develop-skill/references/quick-rules/_index.md +79 -0
  44. package/resources/deveco/skills/hmos-runtime-fix-skill/.deveco-builtin +1 -0
  45. package/resources/deveco/skills/hmos-runtime-fix-skill/SKILL.md +187 -0
  46. package/resources/deveco/skills/hmos-runtime-fix-skill/SKILL_CN.md +160 -0
  47. package/resources/deveco/skills/hmos-runtime-fix-skill/evals/evals.json +17 -0
  48. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/businesserror_patterns.md +17 -0
  49. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/error_patterns.md +31 -0
  50. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/fault-mode-library.md +57 -0
  51. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/outofmemoryerror_patterns.md +19 -0
  52. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/rangeerror_patterns.md +15 -0
  53. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/referenceerror_patterns.md +23 -0
  54. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/syntaxerror_patterns.md +14 -0
  55. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/typeerror_patterns.md +19 -0
  56. package/resources/deveco/skills/hmos-runtime-fix-skill/reference/urierror_patterns.md +17 -0
  57. package/resources/deveco/skills/hmos-runtime-fix-skill/scripts/collect-hilog.mjs +120 -0
  58. package/resources/deveco/skills/hmos-runtime-fix-skill/scripts/jscrash-report.mjs +138 -0
  59. package/resources/deveco/skills/hmos-runtime-fix-skill/scripts/parse-jscrash-log.mjs +126 -0
  60. package/resources/deveco/skills/hmos-runtime-fix-skill/scripts/shared/deveco-cli.mjs +79 -0
  61. package/resources/deveco/skills/hmos-runtime-fix-skill/scripts/shared/jscrash-parse.mjs +389 -0
  62. package/resources/deveco/skills/hmos-runtime-fix-skill/scripts/shared/utils.mjs +27 -0
@@ -0,0 +1,120 @@
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import fs from 'node:fs';
17
+ import fsp from 'node:fs/promises';
18
+ import path from 'node:path';
19
+ import process from 'node:process';
20
+ import { runDevecoCli } from './shared/deveco-cli.mjs';
21
+ import { printKv, toErrorMessage } from './shared/utils.mjs';
22
+
23
+ function cleanLines(input) {
24
+ return input
25
+ .split(/\r?\n/)
26
+ .map((line) => line.trimEnd())
27
+ .filter((line) => line.trim().length > 0);
28
+ }
29
+
30
+ function parseArgs(argv) {
31
+ const map = new Map();
32
+ const optionalKeys = new Set(['device-id']);
33
+
34
+ for (let i = 0; i < argv.length; i += 1) {
35
+ const t = argv[i];
36
+ if (!t.startsWith('--')) {
37
+ continue;
38
+ }
39
+ const key = t.slice(2);
40
+ const val = argv[i + 1];
41
+ if (!val || val.startsWith('--')) {
42
+ if (optionalKeys.has(key)) {
43
+ map.set(key, '');
44
+ continue;
45
+ }
46
+
47
+ throw new Error(`Missing value for --${key}`);
48
+ }
49
+ map.set(key, val);
50
+ i += 1;
51
+ }
52
+
53
+ const outputDir = map.get('output-dir');
54
+ if (!outputDir) {
55
+ throw new Error('Required: --output-dir');
56
+ }
57
+
58
+ return {
59
+ outputDir,
60
+ deviceId: map.get('device-id') ?? '',
61
+ lines: Number(map.get('lines') ?? '4000'),
62
+ };
63
+ }
64
+
65
+ function printCollectFailed(nextAction) {
66
+ printKv({
67
+ status: 'collect_failed',
68
+ source: 'device_hilog',
69
+ log_file: '',
70
+ log_excerpt: '',
71
+ next_action: nextAction,
72
+ });
73
+ }
74
+
75
+ async function collectHilogText(deviceId, lines) {
76
+ const out = await runDevecoCli([
77
+ 'log',
78
+ ...(deviceId ? ['--device', deviceId] : []),
79
+ '--tail',
80
+ String(lines),
81
+ ]);
82
+ if (out.exitCode !== 0) {
83
+ throw new Error(out.stderr || out.stdout || `devecocli log failed (code=${out.exitCode})`);
84
+ }
85
+
86
+ const all = cleanLines(out.stdout);
87
+ return all.slice(Math.max(0, all.length - lines)).join('\n');
88
+ }
89
+
90
+ async function writeHilogSnapshot(outputDir, recent) {
91
+ fs.mkdirSync(outputDir, { recursive: true });
92
+ const logFile = path.join(outputDir, `hilog-${Date.now()}.txt`);
93
+ await fsp.writeFile(logFile, recent, 'utf8');
94
+ return logFile;
95
+ }
96
+
97
+ function printCollected(logFile, recent) {
98
+ printKv({
99
+ status: 'collected',
100
+ source: 'device_hilog',
101
+ log_file: logFile,
102
+ log_excerpt: recent.slice(0, 800),
103
+ next_action: `A hilog snapshot is available. Parse it with parse-jscrash-log.mjs --log-file "${logFile}" --source hilog if you want more crash detail.`,
104
+ });
105
+ }
106
+
107
+ async function main() {
108
+ try {
109
+ const { outputDir, deviceId, lines } = parseArgs(process.argv.slice(2));
110
+ const recent = await collectHilogText(deviceId, lines);
111
+ const logFile = await writeHilogSnapshot(outputDir, recent);
112
+ printCollected(logFile, recent);
113
+ process.exit(0);
114
+ } catch (err) {
115
+ printCollectFailed(toErrorMessage(err));
116
+ process.exit(1);
117
+ }
118
+ }
119
+
120
+ await main();
@@ -0,0 +1,138 @@
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import fs from 'node:fs/promises';
17
+ import process from 'node:process';
18
+ import {
19
+ buildCrashReport,
20
+ buildNextActionText,
21
+ formatCrashReportText,
22
+ } from './shared/jscrash-parse.mjs';
23
+ import { runDevecoCli } from './shared/deveco-cli.mjs';
24
+ import { printKv, toErrorMessage } from './shared/utils.mjs';
25
+
26
+ function parseArgs(argv) {
27
+ const map = new Map();
28
+ const flags = new Set();
29
+ const optionalKeys = new Set(['log-text', 'log-file', 'bundle-name', 'process-hint', 'device-id']);
30
+
31
+ for (let i = 0; i < argv.length; i += 1) {
32
+ const token = argv[i];
33
+ if (token === '--include-text') {
34
+ flags.add('include-text');
35
+ continue;
36
+ }
37
+ if (!token.startsWith('--')) {
38
+ continue;
39
+ }
40
+ const key = token.slice(2);
41
+ const value = argv[i + 1];
42
+ if (!value || value.startsWith('--')) {
43
+ if (optionalKeys.has(key)) {
44
+ map.set(key, '');
45
+ continue;
46
+ }
47
+ throw new Error(`Missing value for --${key}`);
48
+ }
49
+ map.set(key, value);
50
+ i += 1;
51
+ }
52
+
53
+ const logText = map.get('log-text');
54
+ const logFile = map.get('log-file');
55
+ if (logText && logFile) {
56
+ throw new Error('Provide at most one of --log-text or --log-file');
57
+ }
58
+
59
+ return {
60
+ logText,
61
+ logFile,
62
+ bundleName: map.get('bundle-name') ?? '',
63
+ processHint: map.get('process-hint') ?? '',
64
+ deviceId: map.get('device-id') ?? '',
65
+ includeText: flags.has('include-text'),
66
+ };
67
+ }
68
+
69
+ async function collectCrashText(deviceId, bundleName) {
70
+ const out = await runDevecoCli([
71
+ 'log',
72
+ '--crash',
73
+ ...(deviceId ? ['--device', deviceId] : []),
74
+ ...(bundleName ? ['--bundle-name', bundleName] : []),
75
+ ]);
76
+ if (out.exitCode !== 0) {
77
+ throw new Error(out.stderr || out.stdout || `devecocli log --crash failed (code=${out.exitCode})`);
78
+ }
79
+ return out.stdout;
80
+ }
81
+
82
+ async function loadInput(args) {
83
+ if (args.logText) {
84
+ return { text: args.logText, source: 'text' };
85
+ }
86
+ if (args.logFile) {
87
+ return { text: await fs.readFile(args.logFile, 'utf8'), source: 'file' };
88
+ }
89
+ return { text: await collectCrashText(args.deviceId, args.bundleName), source: 'device_crash' };
90
+ }
91
+
92
+ function printReport(report, source, includeText) {
93
+ printKv({
94
+ status: report.status === 'detected' ? 'detected' : 'no_crash_signature',
95
+ source,
96
+ error_type: report.errorType,
97
+ error_message: report.errorMessage,
98
+ suspected_file: report.suspectedFile,
99
+ top_stack: report.topStack.join('|'),
100
+ keywords: report.keywords.join(','),
101
+ next_action: buildNextActionText(report),
102
+ });
103
+
104
+ if (includeText) {
105
+ console.log('');
106
+ console.log(formatCrashReportText(report));
107
+ }
108
+ }
109
+
110
+ async function main() {
111
+ try {
112
+ const args = parseArgs(process.argv.slice(2));
113
+ const input = await loadInput(args);
114
+ const report = buildCrashReport(
115
+ input.text,
116
+ input.source,
117
+ args.deviceId || 'default',
118
+ args.bundleName,
119
+ args.processHint,
120
+ );
121
+ printReport(report, input.source, args.includeText);
122
+ process.exit(0);
123
+ } catch (err) {
124
+ printKv({
125
+ status: 'parse_failed',
126
+ source: 'text',
127
+ error_type: '',
128
+ error_message: '',
129
+ suspected_file: '',
130
+ top_stack: '',
131
+ keywords: '',
132
+ next_action: toErrorMessage(err),
133
+ });
134
+ process.exit(1);
135
+ }
136
+ }
137
+
138
+ await main();
@@ -0,0 +1,126 @@
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import process from 'node:process';
17
+ import fs from 'node:fs/promises';
18
+ import {
19
+ buildCrashReport,
20
+ buildNextActionText,
21
+ formatCrashReportText,
22
+ } from './shared/jscrash-parse.mjs';
23
+ import { printKv, toErrorMessage } from './shared/utils.mjs';
24
+
25
+ function parseArgs(argv) {
26
+ const map = new Map();
27
+ const flags = new Set();
28
+ const optionalKeys = new Set(['bundle-name', 'process-hint', 'device', 'source']);
29
+
30
+ for (let i = 0; i < argv.length; i += 1) {
31
+ const t = argv[i];
32
+ if (t === '--include-text') {
33
+ flags.add('include-text');
34
+ continue;
35
+ }
36
+ if (!t.startsWith('--')) {
37
+ continue;
38
+ }
39
+ const key = t.slice(2);
40
+ const val = argv[i + 1];
41
+ if (!val || val.startsWith('--')) {
42
+ if (optionalKeys.has(key)) {
43
+ map.set(key, '');
44
+ continue;
45
+ }
46
+
47
+ throw new Error(`Missing value for --${key}`);
48
+ }
49
+ map.set(key, val);
50
+ i += 1;
51
+ }
52
+
53
+ const logFile = map.get('log-file');
54
+ const logText = map.get('log-text');
55
+ if ((logFile && logText) || (!logFile && !logText)) {
56
+ throw new Error('Provide exactly one of --log-file or --log-text');
57
+ }
58
+
59
+ return {
60
+ logFile,
61
+ logText,
62
+ bundleName: map.get('bundle-name') ?? '',
63
+ processHint: map.get('process-hint') ?? '',
64
+ source: map.get('source') ?? (logFile ? 'file' : 'text'),
65
+ device: map.get('device') ?? 'default',
66
+ includeText: flags.has('include-text'),
67
+ };
68
+ }
69
+
70
+ async function readLogText(logFile) {
71
+ try {
72
+ return await fs.readFile(logFile, 'utf8');
73
+ } catch {
74
+ throw new Error(`log file not found: ${logFile}`);
75
+ }
76
+ }
77
+
78
+ async function main() {
79
+ try {
80
+ const args = parseArgs(process.argv.slice(2));
81
+ let raw = '';
82
+ if (args.logFile) {
83
+ raw = await readLogText(args.logFile);
84
+ } else if (args.logText) {
85
+ raw = args.logText;
86
+ }
87
+
88
+ const report = buildCrashReport(raw, args.source, args.device, args.bundleName, args.processHint);
89
+ const nextAction = buildNextActionText(report);
90
+
91
+ const topStackJoined = report.topStack.join('|');
92
+ const keywordsJoined = report.keywords.join(',');
93
+
94
+ printKv({
95
+ status: report.status === 'detected' ? 'detected' : 'no_crash_signature',
96
+ source: args.source,
97
+ error_type: report.errorType,
98
+ error_message: report.errorMessage,
99
+ suspected_file: report.suspectedFile,
100
+ top_stack: topStackJoined,
101
+ keywords: keywordsJoined,
102
+ next_action: nextAction,
103
+ });
104
+
105
+ if (args.includeText) {
106
+ console.log('');
107
+ console.log(formatCrashReportText(report));
108
+ }
109
+
110
+ process.exit(0);
111
+ } catch (err) {
112
+ printKv({
113
+ status: 'parse_failed',
114
+ source: 'text',
115
+ error_type: '',
116
+ error_message: '',
117
+ suspected_file: '',
118
+ top_stack: '',
119
+ keywords: '',
120
+ next_action: toErrorMessage(err),
121
+ });
122
+ process.exit(1);
123
+ }
124
+ }
125
+
126
+ await main();
@@ -0,0 +1,79 @@
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ import { spawn } from 'node:child_process';
17
+ import fs from 'node:fs/promises';
18
+ import path from 'node:path';
19
+ import process from 'node:process';
20
+
21
+ export async function runDevecoCli(args) {
22
+ const invocation = await resolveDevecoCli();
23
+ return new Promise((resolve, reject) => {
24
+ const child = spawn(invocation.command, [...invocation.args, ...args], {
25
+ windowsHide: true,
26
+ stdio: ['ignore', 'pipe', 'pipe'],
27
+ });
28
+ let stdout = '';
29
+ let stderr = '';
30
+ child.stdout.setEncoding('utf8');
31
+ child.stderr.setEncoding('utf8');
32
+ child.stdout.on('data', (chunk) => {
33
+ stdout += chunk;
34
+ });
35
+ child.stderr.on('data', (chunk) => {
36
+ stderr += chunk;
37
+ });
38
+ child.on('error', reject);
39
+ child.on('close', (exitCode) => resolve({ stdout, stderr, exitCode: exitCode ?? 1 }));
40
+ });
41
+ }
42
+
43
+ async function resolveDevecoCli() {
44
+ if (process.platform !== 'win32') {
45
+ return { command: 'devecocli', args: [] };
46
+ }
47
+
48
+ const directories = String(process.env.PATH || process.env.Path || '')
49
+ .split(path.delimiter)
50
+ .map((directory) => directory.trim().replace(/^"|"$/g, ''))
51
+ .filter((directory) => directory.length > 0);
52
+
53
+ for (const directory of directories) {
54
+ const executable = path.join(directory, 'devecocli.exe');
55
+ if (await exists(executable)) {
56
+ return { command: executable, args: [] };
57
+ }
58
+
59
+ const shim = path.join(directory, 'devecocli.cmd');
60
+ const pointer = path.join(directory, '.deveco-cli-path');
61
+ if (!(await exists(shim)) || !(await exists(pointer))) {
62
+ continue;
63
+ }
64
+
65
+ const entry = (await fs.readFile(pointer, 'utf8')).trim();
66
+ if (entry && (await exists(entry))) {
67
+ return { command: process.execPath, args: [entry] };
68
+ }
69
+ }
70
+
71
+ throw new Error('devecocli executable was not found in PATH');
72
+ }
73
+
74
+ function exists(file) {
75
+ return fs.access(file).then(
76
+ () => true,
77
+ () => false,
78
+ );
79
+ }